commit
caf9af07ae
2 changed files with 15 additions and 1 deletions
|
|
@ -1707,7 +1707,7 @@ float sfz::Region::getBasePitchVariation(float noteNumber, float velocity) const
|
||||||
auto pitchVariationInCents = pitchKeytrack * (noteNumber - pitchKeycenter); // note difference with pitch center
|
auto pitchVariationInCents = pitchKeytrack * (noteNumber - pitchKeycenter); // note difference with pitch center
|
||||||
pitchVariationInCents += tune; // sample tuning
|
pitchVariationInCents += tune; // sample tuning
|
||||||
pitchVariationInCents += config::centPerSemitone * transpose; // sample transpose
|
pitchVariationInCents += config::centPerSemitone * transpose; // sample transpose
|
||||||
pitchVariationInCents += static_cast<int>(velocity) * pitchVeltrack; // track velocity
|
pitchVariationInCents += velocity * pitchVeltrack; // track velocity
|
||||||
pitchVariationInCents += pitchDistribution(Random::randomGenerator); // random pitch changes
|
pitchVariationInCents += pitchDistribution(Random::randomGenerator); // random pitch changes
|
||||||
return centsFactor(pitchVariationInCents);
|
return centsFactor(pitchVariationInCents);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1845,3 +1845,17 @@ TEST_CASE("[Region] Offsets with CCs")
|
||||||
midiState.ccEvent(0, 4, 0);
|
midiState.ccEvent(0, 4, 0);
|
||||||
REQUIRE( region.getOffset() == 10 );
|
REQUIRE( region.getOffset() == 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Region] Pitch variation with veltrack")
|
||||||
|
{
|
||||||
|
MidiState midiState;
|
||||||
|
Region region { 0, midiState };
|
||||||
|
|
||||||
|
REQUIRE(region.getBasePitchVariation(60.0, 0_norm) == 1.0);
|
||||||
|
REQUIRE(region.getBasePitchVariation(60.0, 64_norm) == 1.0);
|
||||||
|
REQUIRE(region.getBasePitchVariation(60.0, 127_norm) == 1.0);
|
||||||
|
region.parseOpcode({ "pitch_veltrack", "1200" });
|
||||||
|
REQUIRE(region.getBasePitchVariation(60.0, 0_norm) == 1.0);
|
||||||
|
REQUIRE(region.getBasePitchVariation(60.0, 64_norm) == Approx(centsFactor(600.0)).margin(0.01f));
|
||||||
|
REQUIRE(region.getBasePitchVariation(60.0, 127_norm) == Approx(centsFactor(1200.0)).margin(0.01f));
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue