mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
SamplerPluginDemo: Use both velocity and pressure to control note volumes
This commit is contained in:
parent
d1b669e6ae
commit
61619ec0d5
1 changed files with 7 additions and 2 deletions
|
|
@ -272,7 +272,7 @@ public:
|
|||
jassert (currentlyPlayingNote.keyState == MPENote::keyDown
|
||||
|| currentlyPlayingNote.keyState == MPENote::keyDownAndSustained);
|
||||
|
||||
level .setTargetValue (currentlyPlayingNote.pressure.asUnsignedFloat());
|
||||
level .setTargetValue (currentlyPlayingNote.noteOnVelocity.asUnsignedFloat());
|
||||
frequency.setTargetValue (currentlyPlayingNote.getFrequencyInHertz());
|
||||
|
||||
auto loopPoints = samplerSound->getLoopPointsInSeconds();
|
||||
|
|
@ -282,6 +282,7 @@ public:
|
|||
for (auto smoothed : { &level, &frequency, &loopBegin, &loopEnd })
|
||||
smoothed->reset (currentSampleRate, smoothingLengthInSeconds);
|
||||
|
||||
previousPressure = currentlyPlayingNote.pressure.asUnsignedFloat();
|
||||
currentSamplePos = 0.0;
|
||||
tailOff = 0.0;
|
||||
}
|
||||
|
|
@ -298,7 +299,10 @@ public:
|
|||
|
||||
void notePressureChanged() override
|
||||
{
|
||||
level.setTargetValue (currentlyPlayingNote.pressure.asUnsignedFloat());
|
||||
const auto currentPressure = static_cast<double> (currentlyPlayingNote.pressure.asUnsignedFloat());
|
||||
const auto deltaPressure = currentPressure - previousPressure;
|
||||
level.setTargetValue (jlimit (0.0, 1.0, level.getCurrentValue() + deltaPressure));
|
||||
previousPressure = currentPressure;
|
||||
}
|
||||
|
||||
void notePitchbendChanged() override
|
||||
|
|
@ -489,6 +493,7 @@ private:
|
|||
SmoothedValue<double> frequency { 0 };
|
||||
SmoothedValue<double> loopBegin;
|
||||
SmoothedValue<double> loopEnd;
|
||||
double previousPressure { 0 };
|
||||
double currentSamplePos { 0 };
|
||||
double tailOff { 0 };
|
||||
Direction currentDirection { Direction::forward };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue