Merge pull request #385 from paulfd/offset-ccs
offset_cc were not taken into account
This commit is contained in:
commit
68712140d6
2 changed files with 19 additions and 1 deletions
|
|
@ -1447,7 +1447,7 @@ uint64_t sfz::Region::getOffset(Oversampling factor) const noexcept
|
|||
uint64_t finalOffset = offset + offsetDistribution(Random::randomGenerator);
|
||||
for (const auto& mod: offsetCC)
|
||||
finalOffset += static_cast<uint64_t>(mod.data * midiState.getCCValue(mod.cc));
|
||||
return Default::offsetCCRange.clamp(offset + offsetDistribution(Random::randomGenerator)) * static_cast<uint64_t>(factor);
|
||||
return Default::offsetRange.clamp(finalOffset) * static_cast<uint64_t>(factor);
|
||||
}
|
||||
|
||||
float sfz::Region::getDelay() const noexcept
|
||||
|
|
|
|||
|
|
@ -1905,3 +1905,21 @@ TEST_CASE("[Region] Release and release key")
|
|||
REQUIRE( region.delayedReleases == expected );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Offsets with CCs")
|
||||
{
|
||||
MidiState midiState;
|
||||
Region region { 0, midiState };
|
||||
|
||||
region.parseOpcode({ "offset_cc4", "255" });
|
||||
region.parseOpcode({ "offset", "10" });
|
||||
REQUIRE( region.getOffset() == 10 );
|
||||
midiState.ccEvent(0, 4, 127_norm);
|
||||
REQUIRE( region.getOffset() == 265 );
|
||||
midiState.ccEvent(0, 4, 100_norm);
|
||||
REQUIRE( region.getOffset() == 210 );
|
||||
midiState.ccEvent(0, 4, 10_norm);
|
||||
REQUIRE( region.getOffset() == 30 );
|
||||
midiState.ccEvent(0, 4, 0);
|
||||
REQUIRE( region.getOffset() == 10 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue