diff --git a/examples/Plugins/SamplerPluginDemo.h b/examples/Plugins/SamplerPluginDemo.h index 852093e7fb..c03c901840 100644 --- a/examples/Plugins/SamplerPluginDemo.h +++ b/examples/Plugins/SamplerPluginDemo.h @@ -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 (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 frequency { 0 }; SmoothedValue loopBegin; SmoothedValue loopEnd; + double previousPressure { 0 }; double currentSamplePos { 0 }; double tailOff { 0 }; Direction currentDirection { Direction::forward };