From 4ec32024ce352a299dd2186cbf7ad89ab01fc801 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Thu, 14 Oct 2021 23:37:21 +0200 Subject: [PATCH] Evaluate the curve in extended CCs --- src/sfizz/modulations/sources/Controller.cpp | 21 ++++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/sfizz/modulations/sources/Controller.cpp b/src/sfizz/modulations/sources/Controller.cpp index 7d6caea9..eafffd56 100644 --- a/src/sfizz/modulations/sources/Controller.cpp +++ b/src/sfizz/modulations/sources/Controller.cpp @@ -93,12 +93,11 @@ void ControllerSource::generate(const ModKey& sourceKey, NumericId voiceI const MidiState& ms = res.getMidiState(); bool canShortcut = false; - auto transformValue = [p, &curve](float x) { + auto transformValue = [&] (float x) { return curve.evalNormalized(x); }; - // Ignore the eventual curve for the extended CCs - auto quantize = [p](float x) { + auto quantize = [&] (float x) { if (p.step > 0.0f) return std::trunc(x / p.step) * p.step; @@ -112,7 +111,7 @@ void ControllerSource::generate(const ModKey& sourceKey, NumericId voiceI voice && voice->getTriggerEvent().type == TriggerEventType::NoteOn ? impl_->res_->getMidiState().getPolyAftertouch(voice->getTriggerEvent().number) : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; } @@ -122,7 +121,7 @@ void ControllerSource::generate(const ModKey& sourceKey, NumericId voiceI voice && voice->getTriggerEvent().type == TriggerEventType::NoteOn ? voice->getTriggerEvent().value : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; } @@ -132,42 +131,42 @@ void ControllerSource::generate(const ModKey& sourceKey, NumericId voiceI voice && voice->getTriggerEvent().type == TriggerEventType::NoteOff ? voice->getTriggerEvent().value : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; } case ExtendedCCs::keyboardNoteNumber: { const auto voice = impl_->voiceManager_->getVoiceById(voiceId); const float fillValue = voice ? normalize7Bits(voice->getTriggerEvent().number) : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; } case ExtendedCCs::keyboardNoteGate: { const auto voice = impl_->voiceManager_->getVoiceById(voiceId); const float fillValue = voice ? voice->getExtendedCCValues().noteGate : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; } case ExtendedCCs::unipolarRandom: { const auto voice = impl_->voiceManager_->getVoiceById(voiceId); const float fillValue = voice ? voice->getExtendedCCValues().unipolar : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; } case ExtendedCCs::bipolarRandom: { const auto voice = impl_->voiceManager_->getVoiceById(voiceId); const float fillValue = voice ? voice->getExtendedCCValues().bipolar : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; } case ExtendedCCs::alternate: { const auto voice = impl_->voiceManager_->getVoiceById(voiceId); const float fillValue = voice ? voice->getExtendedCCValues().alternate : 0.0f; - sfz::fill(buffer, quantize(fillValue)); + sfz::fill(buffer, quantize(transformValue(fillValue))); canShortcut = true; break; }