From c53eb68a0aea6b91aeb70e9669e852a4d452a41b Mon Sep 17 00:00:00 2001 From: Roland Rabien Date: Fri, 29 Sep 2023 09:01:29 -0700 Subject: [PATCH] Add custom pitch bend range --- plugin/Resources/layout.json | 13 +++++++------ plugin/Source/Panels.h | 16 +++++++--------- plugin/Source/PluginEditor.cpp | 2 +- plugin/Source/PluginProcessor.cpp | 29 ++++++++++++++++------------- plugin/Source/PluginProcessor.h | 6 +++--- plugin/Source/WavetableVoice.cpp | 14 +++++++++++--- plugin/Source/WavetableVoice.h | 2 +- 7 files changed, 46 insertions(+), 36 deletions(-) diff --git a/plugin/Resources/layout.json b/plugin/Resources/layout.json index a47d233..e7e48b5 100644 --- a/plugin/Resources/layout.json +++ b/plugin/Resources/layout.json @@ -36,9 +36,9 @@ { "id": "adsr", "x": "getX('A')", "y": "getY('Res')", "r": "getR('R')", "b": "getY('A')" } ] }, - { "id": "adsr", "x": "prevR()+1", "y": "prevY()", "w": "210 + 118", "h": 163, "children": + { "id": "adsr", "x": "prevR()+1", "y": "prevY()", "w": "210 + 160", "h": 163, "children": [ - { "id": "A", "x": "118/2", "y": 106, "w": 42, "h": 57 }, + { "id": "A", "x": "160/2", "y": 106, "w": 42, "h": 57 }, { "id": "D", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "S", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "R", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, @@ -125,14 +125,15 @@ { "id": "Predelay", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "Mix", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 } ] }, - { "id": "global", "x": "prevR()+1", "y": "prevY()", "w": 126, "h": 137, "children": + { "id": "global", "x": "prevR()+1", "y": "prevY()", "w": 168, "h": 137, "children": [ - { "id": "Legato", "x": 0, "y": 23, "w": 42, "h": 57 }, + { "id": "Mono", "x": 0, "y": 23, "w": 42, "h": 57 }, + { "id": "Legato", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "Glide", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "Time", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, - { "id": "Mono", "x": 0, "y": "prevB()", "w": 42, "h": 57 }, + { "id": "PB Range", "x": 0, "y": "prevB()", "w": 42, "h": 57 }, { "id": "Voices", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, - { "id": "Level", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 } + { "id": "Level", "x": "prevR() + 42", "y": "prevY()", "w": 42, "h": 57 } ] } ] } \ No newline at end of file diff --git a/plugin/Source/Panels.h b/plugin/Source/Panels.h index 9171c53..3d9c7c1 100644 --- a/plugin/Source/Panels.h +++ b/plugin/Source/Panels.h @@ -458,15 +458,13 @@ public: { setName ("global"); - addControl (new gin::Knob (proc.globalParams.level), 0, 0); - addControl (new gin::Select (proc.globalParams.glideMode), 1, 0); - addControl (new gin::Knob (proc.globalParams.glideRate), 2, 0); - - addControl (new gin::Knob (proc.globalParams.voices), 0, 1); - addControl (new gin::Switch (proc.globalParams.legato), 1, 1); - addControl (new gin::Switch (proc.globalParams.mono), 2, 1); - - setSize (168, 163); + addControl (new gin::Knob (proc.globalParams.level)); + addControl (new gin::Select (proc.globalParams.glideMode)); + addControl (new gin::Knob (proc.globalParams.glideRate)); + addControl (new gin::Knob (proc.globalParams.voices)); + addControl (new gin::Switch (proc.globalParams.legato)); + addControl (new gin::Switch (proc.globalParams.mono)); + addControl (new gin::Knob (proc.globalParams.pitchBend)); } WavetableAudioProcessor& proc; diff --git a/plugin/Source/PluginEditor.cpp b/plugin/Source/PluginEditor.cpp index 701d2cb..76675cc 100644 --- a/plugin/Source/PluginEditor.cpp +++ b/plugin/Source/PluginEditor.cpp @@ -21,7 +21,7 @@ WavetableAudioProcessorEditor::WavetableAudioProcessorEditor (WavetableAudioProc usage.setBounds (45, 12, 150, 16); scope.setBounds (674, 5, 177, 30); - setSize (901, 671); + setSize (943, 671); } WavetableAudioProcessorEditor::~WavetableAudioProcessorEditor() diff --git a/plugin/Source/PluginProcessor.cpp b/plugin/Source/PluginProcessor.cpp index 8f19ddd..0de977f 100644 --- a/plugin/Source/PluginProcessor.cpp +++ b/plugin/Source/PluginProcessor.cpp @@ -280,13 +280,14 @@ void WavetableAudioProcessor::ADSRParams::setup (WavetableAudioProcessor& p) //============================================================================== void WavetableAudioProcessor::GlobalParams::setup (WavetableAudioProcessor& p) { - mono = p.addIntParam ("mono", "Mono", "", "", { 0.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f, enableTextFunction); - glideMode = p.addIntParam ("gMode", "Glide Mode", "Glide", "", { 0.0, 2.0, 0.0, 1.0 }, 0.0f, 0.0f, glideModeTextFunction); - glideRate = p.addExtParam ("gRate", "Glide Time", "Time", "s", { 0.001f, 20.0, 0.0, 0.2f }, 0.3f, 0.0f); - legato = p.addIntParam ("legato", "Legato", "", "", { 0.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f, enableTextFunction); - level = p.addExtParam ("level", "Level", "", "db", { -100.0, 0.0, 1.0, 4.0f }, 0.0, 0.0f); - voices = p.addIntParam ("voices", "Voices", "", "", { 2.0, 40.0, 1.0, 1.0 }, 40.0f, 0.0f); - mpe = p.addIntParam ("mpe", "MPE", "", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction); + mono = p.addIntParam ("mono", "Mono", "", "", { 0.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f, enableTextFunction); + glideMode = p.addIntParam ("gMode", "Glide Mode", "Glide", "", { 0.0, 2.0, 0.0, 1.0 }, 0.0f, 0.0f, glideModeTextFunction); + glideRate = p.addExtParam ("gRate", "Glide Time", "Time", "s", { 0.001f, 20.0, 0.0, 0.2f }, 0.3f, 0.0f); + legato = p.addIntParam ("legato", "Legato", "", "", { 0.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f, enableTextFunction); + level = p.addExtParam ("level", "Level", "", "db", { -100.0, 0.0, 1.0, 4.0f }, 0.0, 0.0f); + voices = p.addIntParam ("voices", "Voices", "", "", { 2.0, 40.0, 1.0, 1.0 }, 40.0f, 0.0f); + mpe = p.addIntParam ("mpe", "MPE", "", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction); + pitchBend = p.addIntParam ("pitchbend", "Pitch Bend", "PB Range", "", { 0.0, 48.0, 1.0, 1.0 }, 2.0f, 0.0f); level->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); }; } @@ -330,11 +331,11 @@ void WavetableAudioProcessor::DelayParams::setup (WavetableAudioProcessor& p) sync = p.addExtParam ("dlSync", "Sync", "", "", { 0.0f, 1.0f, 1.0f, 1.0f}, 0.0f, 0.0f, enableTextFunction); time = p.addExtParam ("dlTime", "Delay", "", "", { 0.0f, 120.0f, 0.0f, 0.3f}, 1.0f, 0.0f); beat = p.addExtParam ("dlBeat", "Delay", "", "", { 0.0f, mxd, 1.0f, 1.0f}, 13.0f, 0.0f, durationTextFunction); - fb = p.addExtParam ("dlFb", "FB", "", "dB", {-100.0f, 0.0f, 0.0f, 5.0f}, -10.0f, 0.1f); - cf = p.addExtParam ("dlCf", "CF", "", "dB", {-100.0f, 0.0f, 0.0f, 5.0f}, -100.0f, 0.1f); - mix = p.addExtParam ("dlMix", "Mix", "", "%", { 0.0f, 100.0f, 0.0f, 1.0f}, 0.5f, 0.1f); + fb = p.addExtParam ("dlFb", "FB", "", "dB", {-100.0f, 0.0f, 0.0f, 5.0f}, -10.0f, 0.0f); + cf = p.addExtParam ("dlCf", "CF", "", "dB", {-100.0f, 0.0f, 0.0f, 5.0f}, -100.0f, 0.0f); + mix = p.addExtParam ("dlMix", "Mix", "", "%", { 0.0f, 100.0f, 0.0f, 1.0f}, 0.5f, 0.0f); - delay = p.addIntParam ("dlDelay", "Delay", "", "", { 0.0f, 120.0f, 0.0f, 1.0f}, 1.0f, {0.1f, gin::SmoothingType::eased}); + delay = p.addIntParam ("dlDelay", "Delay", "", "", { 0.0f, 120.0f, 0.0f, 1.0f}, 1.0f, 0.0f); fb->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); }; cf->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); }; @@ -640,6 +641,7 @@ void WavetableAudioProcessor::setupModMatrix() { modSrcPressure = modMatrix.addPolyModSource ("mpep", "MPE Pressure", false); modSrcTimbre = modMatrix.addPolyModSource ("mpet", "MPE Timbre", false); + modSrcPitchbend = modMatrix.addPolyModSource ("mpebp", "MPE Pitch Bend", true); modScrPitchBend = modMatrix.addMonoModSource ("pb", "Pitch Bend", true); @@ -744,6 +746,7 @@ void WavetableAudioProcessor::processBlock (juce::AudioBuffer& buffer, ju startBlock(); setMPE (globalParams.mpe->isOn()); + setPitchBendRange (globalParams.pitchBend->getUserValueInt()); playhead = getPlayHead(); @@ -940,7 +943,8 @@ void WavetableAudioProcessor::updateParams (int newBlockSize) } else { - delayParams.delay->setUserValue (delayParams.time->getUserValue()); + auto z = delayParams.time->getUserValue(); + delayParams.delay->setUserValue (z); } stereoDelay.setParams (modMatrix.getValue (delayParams.delay), @@ -949,7 +953,6 @@ void WavetableAudioProcessor::updateParams (int newBlockSize) modMatrix.getValue (delayParams.cf)); } - // Update Reverb if (reverbParams.enable->isOn()) { diff --git a/plugin/Source/PluginProcessor.h b/plugin/Source/PluginProcessor.h index 113a258..a5f2390 100644 --- a/plugin/Source/PluginProcessor.h +++ b/plugin/Source/PluginProcessor.h @@ -143,7 +143,7 @@ public: { GlobalParams() = default; - gin::Parameter::Ptr mono, glideMode, glideRate, legato, level, voices, mpe; + gin::Parameter::Ptr mono, glideMode, glideRate, legato, level, voices, mpe, pitchBend; void setup (WavetableAudioProcessor& p); @@ -220,8 +220,8 @@ public: }; //============================================================================== - gin::ModSrcId modSrcPressure, modSrcTimbre, modScrPitchBend, modSrcFilter, - modSrcNote, modSrcVelocity, modSrcStep, modSrcMonoStep; + gin::ModSrcId modSrcPressure, modSrcTimbre, modSrcPitchbend, modScrPitchBend, + modSrcFilter, modSrcNote, modSrcVelocity, modSrcStep, modSrcMonoStep; juce::Array modSrcCC, modSrcMonoLFO, modSrcLFO, modSrcEnv; diff --git a/plugin/Source/WavetableVoice.cpp b/plugin/Source/WavetableVoice.cpp index 73b3fa4..2a24527 100644 --- a/plugin/Source/WavetableVoice.cpp +++ b/plugin/Source/WavetableVoice.cpp @@ -31,7 +31,8 @@ void WavetableVoice::noteStarted() } proc.modMatrix.setPolyValue (*this, proc.modSrcVelocity, note.noteOnVelocity.asUnsignedFloat()); - proc.modMatrix.setPolyValue (*this, proc.modSrcTimbre, note.initialTimbre.asUnsignedFloat()); + proc.modMatrix.setPolyValue (*this, proc.modSrcTimbre, note.timbre.asUnsignedFloat()); + proc.modMatrix.setPolyValue (*this, proc.modSrcPitchbend, note.pitchbend.asUnsignedFloat()); proc.modMatrix.setPolyValue (*this, proc.modSrcPressure, note.pressure.asUnsignedFloat()); juce::ScopedValueSetter svs (disableSmoothing, true); @@ -86,8 +87,9 @@ void WavetableVoice::noteRetriggered() } proc.modMatrix.setPolyValue (*this, proc.modSrcVelocity, note.noteOnVelocity.asUnsignedFloat()); - proc.modMatrix.setPolyValue (*this, proc.modSrcTimbre, note.initialTimbre.asUnsignedFloat()); + proc.modMatrix.setPolyValue (*this, proc.modSrcTimbre, note.timbre.asUnsignedFloat()); proc.modMatrix.setPolyValue (*this, proc.modSrcPressure, note.pressure.asUnsignedFloat()); + proc.modMatrix.setPolyValue (*this, proc.modSrcPitchbend, note.pitchbend.asUnsignedFloat()); updateParams (0); @@ -123,7 +125,13 @@ void WavetableVoice::notePressureChanged() void WavetableVoice::noteTimbreChanged() { auto note = getCurrentlyPlayingNote(); - proc.modMatrix.setPolyValue (*this, proc.modSrcTimbre, note.initialTimbre.asUnsignedFloat()); + proc.modMatrix.setPolyValue (*this, proc.modSrcTimbre, note.timbre.asUnsignedFloat()); +} + +void WavetableVoice::notePitchbendChanged() +{ + auto note = getCurrentlyPlayingNote(); + proc.modMatrix.setPolyValue (*this, proc.modSrcPitchbend, note.pitchbend.asUnsignedFloat()); } void WavetableVoice::setCurrentSampleRate (double newRate) diff --git a/plugin/Source/WavetableVoice.h b/plugin/Source/WavetableVoice.h index af70162..5dc5c81 100644 --- a/plugin/Source/WavetableVoice.h +++ b/plugin/Source/WavetableVoice.h @@ -18,7 +18,7 @@ public: void notePressureChanged() override; void noteTimbreChanged() override; - void notePitchbendChanged() override {} + void notePitchbendChanged() override; void noteKeyStateChanged() override {} void setCurrentSampleRate (double newRate) override;