Clear the default path on a new control header
This commit is contained in:
parent
8d2be44c57
commit
8bc0a9c2f5
4 changed files with 23 additions and 2 deletions
|
|
@ -67,6 +67,7 @@ void sfz::Synth::callback(absl::string_view header, const std::vector<Opcode>& m
|
||||||
handleGlobalOpcodes(members);
|
handleGlobalOpcodes(members);
|
||||||
break;
|
break;
|
||||||
case hash("control"):
|
case hash("control"):
|
||||||
|
defaultPath = ""; // Always reset on a new control header
|
||||||
handleControlOpcodes(members);
|
handleControlOpcodes(members);
|
||||||
break;
|
break;
|
||||||
case hash("master"):
|
case hash("master"):
|
||||||
|
|
|
||||||
|
|
@ -330,17 +330,18 @@ TEST_CASE("[Files] Default path")
|
||||||
{
|
{
|
||||||
sfz::Synth synth;
|
sfz::Synth synth;
|
||||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path.sfz");
|
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(0)->sample == R"(DefaultPath/SubPath1/sample1.wav)");
|
||||||
REQUIRE(synth.getRegionView(1)->sample == R"(DefaultPath/SubPath2/sample2.wav)");
|
REQUIRE(synth.getRegionView(1)->sample == R"(DefaultPath/SubPath2/sample2.wav)");
|
||||||
REQUIRE(synth.getRegionView(2)->sample == R"(DefaultPath/SubPath1/sample1.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")
|
TEST_CASE("[Files] Default path reset when calling loadSfzFile again")
|
||||||
{
|
{
|
||||||
sfz::Synth synth;
|
sfz::Synth synth;
|
||||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path.sfz");
|
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");
|
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path_reset.sfz");
|
||||||
REQUIRE(synth.getNumRegions() == 1);
|
REQUIRE(synth.getNumRegions() == 1);
|
||||||
REQUIRE(synth.getRegionView(0)->sample == R"(DefaultPath/SubPath2/sample2.wav)");
|
REQUIRE(synth.getRegionView(0)->sample == R"(DefaultPath/SubPath2/sample2.wav)");
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,6 @@
|
||||||
|
|
||||||
<control> default_path=DefaultPath/SubPath1/sample
|
<control> default_path=DefaultPath/SubPath1/sample
|
||||||
<region> sample=1.wav
|
<region> sample=1.wav
|
||||||
|
|
||||||
|
<control> // New control headers reset the default path
|
||||||
|
<region> sample=DefaultPath/SubPath2/sample2.wav
|
||||||
|
|
|
||||||
16
tests/TestFiles/note_offset.sfz
Normal file
16
tests/TestFiles/note_offset.sfz
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<control> note_offset=1
|
||||||
|
<region> key=63 sample=*sine
|
||||||
|
<region> lokey=50 hikey=55 pitch_keycenter=50 sample=*sine
|
||||||
|
<region> lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine
|
||||||
|
<control> note_offset=-1
|
||||||
|
<region> key=63 sample=*sine
|
||||||
|
<region> lokey=50 hikey=55 pitch_keycenter=50 sample=*sine
|
||||||
|
<region> lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine
|
||||||
|
<control> note_offset=1 octave_offset=1
|
||||||
|
<region> key=63 sample=*sine
|
||||||
|
<region> lokey=50 hikey=55 pitch_keycenter=50 sample=*sine
|
||||||
|
<region> lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine
|
||||||
|
<control> note_offset=-1 octave_offset=-1
|
||||||
|
<region> key=63 sample=*sine
|
||||||
|
<region> lokey=50 hikey=55 pitch_keycenter=50 sample=*sine
|
||||||
|
<region> lokey=40 hikey=44 pitch_keycenter=40 xfin_lokey=36 xfin_hikey=40 xfout_lokey=36 xfout_hikey=40 sample=*sine
|
||||||
Loading…
Add table
Reference in a new issue