From bd58bd158451a3971f079240dd58b6f4da1f9d25 Mon Sep 17 00:00:00 2001 From: Roland Rabien Date: Sat, 7 Oct 2023 10:57:13 -0700 Subject: [PATCH] Added retrig to ADSRs --- Changelist.txt | 2 + VERSION | 2 +- plugin/Resources/layout.json | 9 ++-- plugin/Source/Panels.h | 70 +++++++++++++++++++------------ plugin/Source/PluginProcessor.cpp | 35 +++++++++------- plugin/Source/PluginProcessor.h | 6 +-- plugin/Source/WavetableVoice.cpp | 11 +++-- 7 files changed, 82 insertions(+), 53 deletions(-) diff --git a/Changelist.txt b/Changelist.txt index 71a3243..012b57f 100644 --- a/Changelist.txt +++ b/Changelist.txt @@ -2,6 +2,8 @@ - Increase performance of Wavetable oscillator - Increase clickable size of next/prev preset buttons +- Add dots to ADSRs +- Add retrig to ADSRs (mono + glissando/portamento only) 1.0.11: diff --git a/VERSION b/VERSION index 8684498..492b167 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.11 \ No newline at end of file +1.0.12 \ No newline at end of file diff --git a/plugin/Resources/layout.json b/plugin/Resources/layout.json index 95e8448..b28e02e 100644 --- a/plugin/Resources/layout.json +++ b/plugin/Resources/layout.json @@ -50,7 +50,8 @@ { "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 }, - { "id": "adsr", "x": "getX('A')", "y": "getY('Res')", "r": "getR('R')", "b": "getY('A')" } + { "id": "adsr", "x": "getX('A')", "y": "getY('Res')", "r": "getR('R')", "b": "getY('A')" }, + { "id": "Retrig", "r": "getR('adsr') - 3", "y": "getY('adsr') + 3", "w": 12, "h": 12 } ] }, { "id": "adsr", "x": "prevR()+1", "y": "prevY()", "w": "210 + 160", "h": 163, "children": @@ -60,7 +61,8 @@ { "id": "S", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "R", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "Vel", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, - { "id": "adsr", "x": 0, "y": 23, "r": "parW()", "b": "getY('A')" } + { "id": "adsr", "x": 0, "y": 23, "r": "parW()", "b": "getY('A')" }, + { "id": "Retrig", "r": "getR('adsr') - 3", "y": "getY('adsr') + 3", "w": 12, "h": 12 } ] }, { "id": "lfo[1..3]", "x": 0, "y": "prevB()+1,prevY()", "w": 280, "h": 163, "children": [ @@ -82,7 +84,8 @@ { "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 }, - { "id": "adsr", "x": 0, "y": 23, "r": "parW()", "b": "getY('A')" } + { "id": "adsr", "x": 0, "y": 23, "r": "parW()", "b": "getY('A')" }, + { "id": "Retrig", "r": "getR('adsr') - 3", "y": "getY('adsr') + 3", "w": 12, "h": 12 } ] }, { "id": "step", "x": "prevR()+1", "y": "prevY()", "w": 218, "h": 163, "children": [ diff --git a/plugin/Source/Panels.h b/plugin/Source/Panels.h index 1dff914..2412fcb 100644 --- a/plugin/Source/Panels.h +++ b/plugin/Source/Panels.h @@ -267,11 +267,24 @@ public: addControl (new gin::Knob (preset.sustain), 2, 1); addControl (new gin::Knob (preset.release), 3, 1); addControl (new gin::Knob (preset.velocityTracking), 4, 1); + addControl (retrig = new gin::SVGPluginButton (preset.retrig, gin::Assets::retrigger)); + + watchParam (proc.globalParams.mono); + watchParam (proc.globalParams.glideMode); + } + + void paramChanged() override + { + gin::ParamBox::paramChanged (); + + if (retrig != nullptr) + retrig->setVisible (proc.globalParams.mono->isOn() && proc.globalParams.glideMode->getUserValue() > 0); } WavetableAudioProcessor& proc; - gin::ParamComponent::Ptr a, d, s, r; - gin::ADSRComponent* adsr; + gin::ParamComponent::Ptr a = nullptr, d = nullptr, s = nullptr, r = nullptr; + gin::ADSRComponent* adsr = nullptr; + gin::SVGPluginButton* retrig; }; //============================================================================== @@ -290,13 +303,13 @@ public: addModSource (new gin::ModulationSourceButton (proc.modMatrix, proc.modSrcFilter, true)); auto freq = new gin::Knob (flt.frequency); - addControl (freq, 0, 0); - addControl (new gin::Knob (flt.resonance), 1, 0); - addControl (new gin::Knob (flt.amount, true), 2, 0); + addControl (freq); + addControl (new gin::Knob (flt.resonance)); + addControl (new gin::Knob (flt.amount, true)); - addControl (new gin::Knob (flt.keyTracking), 0, 1); - addControl (new gin::Select (flt.type), 1, 1); - addControl (v = new gin::Knob (flt.velocityTracking), 2, 1); + addControl (new gin::Knob (flt.keyTracking)); + addControl (new gin::Select (flt.type)); + addControl (v = new gin::Knob (flt.velocityTracking)); adsr = new gin::ADSRComponent (); adsr->setParams (flt.attack, flt.decay, flt.sustain, flt.release); @@ -333,8 +346,11 @@ public: addControl (new gin::SVGPluginButton (flt.wt2, asset2)); addControl (new gin::SVGPluginButton (flt.sub, assetS)); addControl (new gin::SVGPluginButton (flt.noise, assetN)); + addControl (retrig = new gin::SVGPluginButton (flt.retrig, gin::Assets::retrigger)); watchParam (flt.amount); + watchParam (proc.globalParams.mono); + watchParam (proc.globalParams.glideMode); } void paramChanged () override @@ -349,11 +365,16 @@ public: s->setEnabled (flt.amount->getUserValue() != 0.0f); r->setEnabled (flt.amount->getUserValue() != 0.0f); adsr->setEnabled (flt.amount->getUserValue() != 0.0f); + + if (retrig != nullptr) + retrig->setVisible (proc.globalParams.mono->isOn() && proc.globalParams.glideMode->getUserValue() > 0); } + WavetableAudioProcessor& proc; - gin::ParamComponent::Ptr v, a, d, s, r; - gin::ADSRComponent* adsr; + gin::ParamComponent::Ptr v = nullptr, a = nullptr, d = nullptr, s = nullptr, r = nullptr; + gin::ADSRComponent* adsr = nullptr; + gin::SVGPluginButton* retrig = nullptr; juce::String asset1 = "M0 96C0 60.7 28.7 32 64 32H384c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zm236 35.2c-7.4-4.3-16.5-4.3-24-.1l-56 32c-11.5 6.6-15.5 21.2-8.9 32.7s21.2 15.5 32.7 8.9L200 193.4V336H160c-13.3 0-24 10.7-24 24s10.7 24 24 24h64 64c13.3 0 24-10.7 24-24s-10.7-24-24-24H248V152c0-8.6-4.6-16.5-12-20.8z"; juce::String asset2 = "M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zM190.7 184.7l-24.2 18.4c-10.5 8-25.6 6-33.6-4.5s-6-25.6 4.5-33.6l24.2-18.4c15.8-12 35.2-18.4 55.1-18.1l3.4 .1c46.5 .7 83.8 38.6 83.8 85.1c0 23.5-9.7 46-26.9 62.1L212.7 336H296c13.3 0 24 10.7 24 24s-10.7 24-24 24H152c-9.8 0-18.7-6-22.3-15.2s-1.3-19.6 5.9-26.3L244.3 240.6c7.5-7 11.7-16.8 11.7-27.1c0-20.3-16.3-36.8-36.6-37.1l-3.4-.1c-9.1-.1-18 2.8-25.3 8.3z"; @@ -407,13 +428,11 @@ public: return res; }; l->setParams (lfo.wave, lfo.sync, lfo.rate, lfo.beat, lfo.depth, lfo.offset, lfo.phase, lfo.enable); - addControl (l, 2, 0, 4, 1); + addControl (l); addControl (new gin::SVGPluginButton (lfo.retrig, gin::Assets::retrigger)); watchParam (lfo.sync); - - setSize (112, 163); } void paramChanged () override @@ -472,11 +491,22 @@ public: return res; }; addControl (g, 0, 0, 4, 1); + addControl (retrig = new gin::SVGPluginButton (env.retrig, gin::Assets::retrigger)); - setSize (112, 163); + watchParam (proc.globalParams.mono); + watchParam (proc.globalParams.glideMode); + } + + void paramChanged () override + { + gin::ParamBox::paramChanged (); + + if (retrig != nullptr) + retrig->setVisible (proc.globalParams.mono->isOn() && proc.globalParams.glideMode->getUserValue() > 0); } WavetableAudioProcessor& proc; + gin::SVGPluginButton* retrig = nullptr; int idx; }; @@ -519,8 +549,6 @@ public: addControl (g, 0, 0, 4, 1); addControl (new gin::SVGPluginButton (prs.retrig, gin::Assets::retrigger)); - - setSize (112, 163); } WavetableAudioProcessor& proc; @@ -618,8 +646,6 @@ public: auto g = new gin::GateEffectComponent (Cfg::numGateSteps); g->setParams (proc.gateParams.length, proc.gateParams.l, proc.gateParams.r, proc.gateParams.enable); addControl (g, 0, 1, 4, 1); - - setSize (112, 163); } WavetableAudioProcessor& proc; @@ -642,8 +668,6 @@ public: addControl (new gin::Knob (proc.chorusParams.depth), 0.5f, 1.0f); addControl (new gin::Knob (proc.chorusParams.width), 1.5f, 1.0f); - - setSize (168, 163); } WavetableAudioProcessor& proc; @@ -661,8 +685,6 @@ public: addEnable (proc.distortionParams.enable); addControl (new gin::Knob (proc.distortionParams.amount), 0, 0); - - setSize (112, 163); } WavetableAudioProcessor& proc; @@ -691,8 +713,6 @@ public: b->setName ("Delay2"); watchParam (proc.delayParams.sync); - - setSize (168, 163); } void paramChanged () override @@ -724,8 +744,6 @@ public: addControl (new gin::Knob (proc.reverbParams.damping), 0, 1); addControl (new gin::Knob (proc.reverbParams.predelay), 1, 1); addControl (new gin::Knob (proc.reverbParams.mix), 2, 1); - - setSize (168, 163); } WavetableAudioProcessor& proc; diff --git a/plugin/Source/PluginProcessor.cpp b/plugin/Source/PluginProcessor.cpp index 3eae156..6d6ebe7 100644 --- a/plugin/Source/PluginProcessor.cpp +++ b/plugin/Source/PluginProcessor.cpp @@ -169,21 +169,22 @@ void WavetableAudioProcessor::FilterParams::setup (WavetableAudioProcessor& p) float maxFreq = float (gin::getMidiNoteFromHertz (20000.0)); - enable = p.addIntParam (id + "enable", nm + "Enable", "", "", { 0.0, 1.0, 1.0, 1.0 }, 1.0f, 0.0f); - type = p.addIntParam (id + "type", nm + "Type", "Type", "", { 0.0, 7.0, 1.0, 1.0 }, 0.0, 0.0f, filterTextFunction); - keyTracking = p.addExtParam (id + "key", nm + "Key", "Key", "%", { 0.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f); - velocityTracking = p.addExtParam (id + "vel", nm + "Vel", "Vel", "%", { 0.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f); - frequency = p.addExtParam (id + "freq", nm + "Freq", "Freq", "Hz", { 0.0, maxFreq, 0.0, 1.0 }, 64.0, 0.0f, freqTextFunction); - resonance = p.addExtParam (id + "res", nm + "Res", "Res", "", { 0.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f); - amount = p.addExtParam (id + "amount", nm + "Amount", "Amnt", "", { -1.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f); - attack = p.addExtParam (id + "attack", nm + "Attack", "A", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); - decay = p.addExtParam (id + "decay", nm + "Decay", "D", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); - sustain = p.addExtParam (id + "sustain", nm + "Sustain", "S", "%", { 0.0, 100.0, 0.0, 1.0 }, 80.0f, 0.0f); - release = p.addExtParam (id + "release", nm + "Release", "R", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); - wt1 = p.addIntParam (id + "wt1", nm + "WT1", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); - wt2 = p.addIntParam (id + "wt2", nm + "WT2", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); - sub = p.addIntParam (id + "sub", nm + "sub", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); - noise = p.addIntParam (id + "noise", nm + "noise", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); + enable = p.addIntParam (id + "enable", nm + "Enable", "", "", { 0.0, 1.0, 1.0, 1.0 }, 1.0f, 0.0f); + retrig = p.addIntParam (id + "retrig", nm + "Retrig", "Retrig", "", { 0.0, 1.0, 1.0, 1.0 }, 1.0, 0.0f, enableTextFunction); + type = p.addIntParam (id + "type", nm + "Type", "Type", "", { 0.0, 7.0, 1.0, 1.0 }, 0.0, 0.0f, filterTextFunction); + keyTracking = p.addExtParam (id + "key", nm + "Key", "Key", "%", { 0.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f); + velocityTracking = p.addExtParam (id + "vel", nm + "Vel", "Vel", "%", { 0.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f); + frequency = p.addExtParam (id + "freq", nm + "Freq", "Freq", "Hz", { 0.0, maxFreq, 0.0, 1.0 }, 64.0, 0.0f, freqTextFunction); + resonance = p.addExtParam (id + "res", nm + "Res", "Res", "", { 0.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f); + amount = p.addExtParam (id + "amount", nm + "Amount", "Amnt", "", { -1.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f); + attack = p.addExtParam (id + "attack", nm + "Attack", "A", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); + decay = p.addExtParam (id + "decay", nm + "Decay", "D", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); + sustain = p.addExtParam (id + "sustain", nm + "Sustain", "S", "%", { 0.0, 100.0, 0.0, 1.0 }, 80.0f, 0.0f); + release = p.addExtParam (id + "release", nm + "Release", "R", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); + wt1 = p.addIntParam (id + "wt1", nm + "WT1", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); + wt2 = p.addIntParam (id + "wt2", nm + "WT2", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); + sub = p.addIntParam (id + "sub", nm + "sub", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); + noise = p.addIntParam (id + "noise", nm + "noise", "", "", { 0.0, 1.0, 1.0, 1.0f }, 1.0f, 0.0f); sustain->conversionFunction = [] (float in) { return in / 100.0f; }; velocityTracking->conversionFunction = [] (float in) { return in / 100.0f; }; @@ -197,6 +198,7 @@ void WavetableAudioProcessor::EnvParams::setup (WavetableAudioProcessor& p, int juce::String nm = "ENV" + juce::String (idx + 1) + " "; enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0, 0.0f, enableTextFunction); + retrig = p.addIntParam (id + "retrig", nm + "Retrig", "Retrig", "", { 0.0, 1.0, 1.0, 1.0 }, 1.0, 0.0f, enableTextFunction); attack = p.addExtParam (id + "attack", nm + "Attack", "A", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); decay = p.addExtParam (id + "decay", nm + "Decay", "D", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); sustain = p.addExtParam (id + "sustain", nm + "Sustain", "S", "%", { 0.0, 100.0, 0.0, 1.0 }, 80.0f, 0.0f); @@ -271,7 +273,8 @@ void WavetableAudioProcessor::GateParams::setup (WavetableAudioProcessor& p) //============================================================================== void WavetableAudioProcessor::ADSRParams::setup (WavetableAudioProcessor& p) { - velocityTracking = p.addExtParam ("vel", "Vel", "Vel", "", { 0.0, 100.0, 0.0, 1.0 }, 100.0, 0.0f); + retrig = p.addIntParam ("retrig", "Retrig", "Retrig","", { 0.0, 1.0, 1.0, 1.0 }, 1.0f, 0.0f, enableTextFunction); + velocityTracking = p.addExtParam ("vel", "Vel", "Vel", "", { 0.0, 100.0, 0.0, 1.0 }, 100.0f, 0.0f); attack = p.addExtParam ("attack", "Attack", "A", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); decay = p.addExtParam ("decay", "Decay", "D", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f); sustain = p.addExtParam ("sustain", "Sustain", "S", "%", { 0.0, 100.0, 0.0, 1.0 }, 80.0f, 0.0f); diff --git a/plugin/Source/PluginProcessor.h b/plugin/Source/PluginProcessor.h index aa80deb..7165afa 100644 --- a/plugin/Source/PluginProcessor.h +++ b/plugin/Source/PluginProcessor.h @@ -86,7 +86,7 @@ public: FilterParams() = default; gin::Parameter::Ptr enable, type, keyTracking, velocityTracking, - frequency, resonance, amount, + frequency, resonance, amount, retrig, attack, decay, sustain, release, wt1, wt2, sub, noise; void setup (WavetableAudioProcessor& p); @@ -98,7 +98,7 @@ public: { EnvParams() = default; - gin::Parameter::Ptr enable, attack, decay, sustain, release; + gin::Parameter::Ptr enable, attack, decay, sustain, release, retrig; void setup (WavetableAudioProcessor& p, int idx); @@ -132,7 +132,7 @@ public: { ADSRParams() = default; - gin::Parameter::Ptr attack, decay, sustain, release, velocityTracking; + gin::Parameter::Ptr attack, decay, sustain, release, velocityTracking, retrig; void setup (WavetableAudioProcessor& p); diff --git a/plugin/Source/WavetableVoice.cpp b/plugin/Source/WavetableVoice.cpp index b08a874..b4fb58f 100644 --- a/plugin/Source/WavetableVoice.cpp +++ b/plugin/Source/WavetableVoice.cpp @@ -119,12 +119,15 @@ void WavetableVoice::noteRetriggered() updateParams (0); - filterADSR.noteOn(); + if (proc.filterParams.retrig->getBoolValue()) + filterADSR.noteOn(); - for (auto& a : modADSRs) - a.noteOn(); + for (auto idx = 0; auto& a : modADSRs) + if (proc.envParams[idx++].retrig->getBoolValue()) + a.noteOn(); - adsr.noteOn(); + if (proc.adsrParams.retrig->getBoolValue()) + adsr.noteOn(); } void WavetableVoice::noteStopped (bool allowTailOff)