Corrected a bug with default_path
Generators should ignore the default_path
This commit is contained in:
parent
92254e8c98
commit
dc879a8a07
3 changed files with 20 additions and 1 deletions
|
|
@ -43,7 +43,16 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
||||||
switch (hash(opcode.opcode)) {
|
switch (hash(opcode.opcode)) {
|
||||||
// Sound source: sample playback
|
// Sound source: sample playback
|
||||||
case hash("sample"):
|
case hash("sample"):
|
||||||
sample = absl::StrCat(defaultPath, absl::StrReplaceAll(trim(opcode.value), { { "\\", "/" } }));
|
{
|
||||||
|
const auto trimmedSample = trim(opcode.value);
|
||||||
|
if (trimmedSample.empty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (trimmedSample[0] == '*')
|
||||||
|
sample = std::string(trimmedSample);
|
||||||
|
else
|
||||||
|
sample = absl::StrCat(defaultPath, absl::StrReplaceAll(trim(opcode.value), { { "\\", "/" } }));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case hash("delay"):
|
case hash("delay"):
|
||||||
setValueFromOpcode(opcode, delay, Default::delayRange);
|
setValueFromOpcode(opcode, delay, Default::delayRange);
|
||||||
|
|
|
||||||
|
|
@ -380,4 +380,12 @@ TEST_CASE("[Files] Default path reset when calling loadSfzFile again")
|
||||||
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)");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Files] Default path is ignored for generators")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path_generator.sfz");
|
||||||
|
REQUIRE(synth.getNumRegions() == 1);
|
||||||
|
REQUIRE(synth.getRegionView(0)->sample == R"(*sine)");
|
||||||
}
|
}
|
||||||
2
tests/TestFiles/default_path_generator.sfz
Normal file
2
tests/TestFiles/default_path_generator.sfz
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<control> default_path=DefaultPath/SubPath1
|
||||||
|
<region> sample=*sine
|
||||||
Loading…
Add table
Reference in a new issue