Explicitely signify if a loop if present

Before we tried to "guess", which causes problems if a loop spans the entire file
This commit is contained in:
Paul Ferrand 2020-08-18 23:09:03 +02:00
parent be7ff64a17
commit da75095a9b
5 changed files with 14 additions and 1 deletions

View file

@ -227,6 +227,7 @@ absl::optional<sfz::FileInformation> sfz::FilePool::getFileInformation(const Fil
if (!fileId.isReverse()) {
if (instrumentInfo.loop_count > 0) {
returnedValue.hasLoop = true;
returnedValue.loopBegin = instrumentInfo.loops[0].start;
returnedValue.loopEnd = min(returnedValue.end, instrumentInfo.loops[0].end - 1);
}

View file

@ -52,6 +52,7 @@ struct FileInformation {
uint32_t end { Default::sampleEndRange.getEnd() };
uint32_t loopBegin { Default::loopRange.getStart() };
uint32_t loopEnd { Default::loopRange.getEnd() };
bool hasLoop { false };
double sampleRate { config::defaultSampleRate };
int numChannels { 0 };
};

View file

@ -482,7 +482,7 @@ void sfz::Synth::finalizeSfzLoad()
region->sampleEnd = std::min(region->sampleEnd, fileInformation->end);
if (fileInformation->loopBegin != Default::loopRange.getStart() && fileInformation->loopEnd != Default::loopRange.getEnd()) {
if (fileInformation->hasLoop) {
if (region->loopRange.getStart() == Default::loopRange.getStart())
region->loopRange.setStart(fileInformation->loopBegin);

View file

@ -564,6 +564,17 @@ TEST_CASE("[Files] Looped regions taken from files and possibly overriden")
REQUIRE(synth.getRegionView(2)->loopRange == Range<uint32_t> { 4, 124 });
}
TEST_CASE("[Files] Looped regions can start at 0")
{
Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/loop_can_start_at_0.sfz", R"(
<region> sample=wavetable_with_loop_at_endings.wav
)");
REQUIRE( synth.getNumRegions() == 1 );
REQUIRE( synth.getRegionView(0)->loopMode == SfzLoopMode::loop_continuous );
REQUIRE( synth.getRegionView(0)->loopRange == Range<uint32_t> { 0, synth.getRegionView(0)->sampleEnd } );
}
TEST_CASE("[Files] Case sentitiveness")
{
const fs::path sfzFilePath = fs::current_path() / "tests/TestFiles/case_insensitive.sfz";

Binary file not shown.