Merge pull request #378 from paulfd/loop-start-0
Explicitely signify if a loop if present
This commit is contained in:
commit
d442812604
5 changed files with 14 additions and 1 deletions
|
|
@ -227,6 +227,7 @@ absl::optional<sfz::FileInformation> sfz::FilePool::getFileInformation(const Fil
|
||||||
|
|
||||||
if (!fileId.isReverse()) {
|
if (!fileId.isReverse()) {
|
||||||
if (instrumentInfo.loop_count > 0) {
|
if (instrumentInfo.loop_count > 0) {
|
||||||
|
returnedValue.hasLoop = true;
|
||||||
returnedValue.loopBegin = instrumentInfo.loops[0].start;
|
returnedValue.loopBegin = instrumentInfo.loops[0].start;
|
||||||
returnedValue.loopEnd = min(returnedValue.end, instrumentInfo.loops[0].end - 1);
|
returnedValue.loopEnd = min(returnedValue.end, instrumentInfo.loops[0].end - 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ struct FileInformation {
|
||||||
uint32_t end { Default::sampleEndRange.getEnd() };
|
uint32_t end { Default::sampleEndRange.getEnd() };
|
||||||
uint32_t loopBegin { Default::loopRange.getStart() };
|
uint32_t loopBegin { Default::loopRange.getStart() };
|
||||||
uint32_t loopEnd { Default::loopRange.getEnd() };
|
uint32_t loopEnd { Default::loopRange.getEnd() };
|
||||||
|
bool hasLoop { false };
|
||||||
double sampleRate { config::defaultSampleRate };
|
double sampleRate { config::defaultSampleRate };
|
||||||
int numChannels { 0 };
|
int numChannels { 0 };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -482,7 +482,7 @@ void sfz::Synth::finalizeSfzLoad()
|
||||||
|
|
||||||
region->sampleEnd = std::min(region->sampleEnd, fileInformation->end);
|
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())
|
if (region->loopRange.getStart() == Default::loopRange.getStart())
|
||||||
region->loopRange.setStart(fileInformation->loopBegin);
|
region->loopRange.setStart(fileInformation->loopBegin);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 });
|
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")
|
TEST_CASE("[Files] Case sentitiveness")
|
||||||
{
|
{
|
||||||
const fs::path sfzFilePath = fs::current_path() / "tests/TestFiles/case_insensitive.sfz";
|
const fs::path sfzFilePath = fs::current_path() / "tests/TestFiles/case_insensitive.sfz";
|
||||||
|
|
|
||||||
BIN
tests/TestFiles/wavetable_with_loop_at_endings.wav
Normal file
BIN
tests/TestFiles/wavetable_with_loop_at_endings.wav
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue