diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index c809270e..b0e145b7 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -67,6 +67,7 @@ void sfz::Synth::callback(absl::string_view header, const std::vector& m handleGlobalOpcodes(members); break; case hash("control"): + defaultPath = ""; // Always reset on a new control header handleControlOpcodes(members); break; case hash("master"): diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index cd2bb267..bd709e92 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -330,17 +330,18 @@ TEST_CASE("[Files] Default path") { sfz::Synth synth; synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path.sfz"); - REQUIRE(synth.getNumRegions() == 3); + REQUIRE(synth.getNumRegions() == 4); REQUIRE(synth.getRegionView(0)->sample == R"(DefaultPath/SubPath1/sample1.wav)"); REQUIRE(synth.getRegionView(1)->sample == R"(DefaultPath/SubPath2/sample2.wav)"); REQUIRE(synth.getRegionView(2)->sample == R"(DefaultPath/SubPath1/sample1.wav)"); + REQUIRE(synth.getRegionView(3)->sample == R"(DefaultPath/SubPath2/sample2.wav)"); } TEST_CASE("[Files] Default path reset when calling loadSfzFile again") { sfz::Synth synth; synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path.sfz"); - REQUIRE(synth.getNumRegions() == 3); + REQUIRE(synth.getNumRegions() == 4); synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path_reset.sfz"); REQUIRE(synth.getNumRegions() == 1); REQUIRE(synth.getRegionView(0)->sample == R"(DefaultPath/SubPath2/sample2.wav)"); diff --git a/tests/TestFiles/default_path.sfz b/tests/TestFiles/default_path.sfz index d77c61ea..da158894 100644 --- a/tests/TestFiles/default_path.sfz +++ b/tests/TestFiles/default_path.sfz @@ -5,3 +5,6 @@ default_path=DefaultPath/SubPath1/sample sample=1.wav + + // New control headers reset the default path + sample=DefaultPath/SubPath2/sample2.wav diff --git a/tests/TestFiles/note_offset.sfz b/tests/TestFiles/note_offset.sfz new file mode 100644 index 00000000..d372cc30 --- /dev/null +++ b/tests/TestFiles/note_offset.sfz @@ -0,0 +1,16 @@ + note_offset=1 + key=63 sample=*sine + lokey=50 hikey=55 pitch_keycenter=50 sample=*sine + lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine + note_offset=-1 + key=63 sample=*sine + lokey=50 hikey=55 pitch_keycenter=50 sample=*sine + lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine + note_offset=1 octave_offset=1 + key=63 sample=*sine + lokey=50 hikey=55 pitch_keycenter=50 sample=*sine + lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine + note_offset=-1 octave_offset=-1 + key=63 sample=*sine + lokey=50 hikey=55 pitch_keycenter=50 sample=*sine + lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine