diff --git a/src/sfizz/Region.cpp b/src/sfizz/Region.cpp index 3ab0c267..b304ca2a 100644 --- a/src/sfizz/Region.cpp +++ b/src/sfizz/Region.cpp @@ -43,7 +43,16 @@ bool sfz::Region::parseOpcode(const Opcode& opcode) switch (hash(opcode.opcode)) { // Sound source: sample playback 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; case hash("delay"): setValueFromOpcode(opcode, delay, Default::delayRange); diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index bbc8bf23..88c2f316 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -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"); REQUIRE(synth.getNumRegions() == 1); 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)"); } \ No newline at end of file diff --git a/tests/TestFiles/default_path_generator.sfz b/tests/TestFiles/default_path_generator.sfz new file mode 100644 index 00000000..8b7b652f --- /dev/null +++ b/tests/TestFiles/default_path_generator.sfz @@ -0,0 +1,2 @@ + default_path=DefaultPath/SubPath1 + sample=*sine \ No newline at end of file