From 73b34ded3fd0b317e1cc4d49bcbcb0b3cb2c8d76 Mon Sep 17 00:00:00 2001 From: Roland Rabien Date: Tue, 3 Oct 2023 08:11:07 -0700 Subject: [PATCH] Add retrig to OSCs --- modules/gin | 2 +- plugin/Resources/layout.json | 2 ++ plugin/Source/Panels.h | 2 ++ plugin/Source/PluginProcessor.cpp | 4 +++- plugin/Source/PluginProcessor.h | 4 ++-- plugin/Source/WavetableVoice.cpp | 6 +++--- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/gin b/modules/gin index a03d9fc..f8c67b8 160000 --- a/modules/gin +++ b/modules/gin @@ -1 +1 @@ -Subproject commit a03d9fcc37cc708f5fdf8ade35037438651d1ecf +Subproject commit f8c67b8a184bc33b7470889a44e984e6cc7b5f8a diff --git a/plugin/Resources/layout.json b/plugin/Resources/layout.json index d2d6578..95e8448 100644 --- a/plugin/Resources/layout.json +++ b/plugin/Resources/layout.json @@ -3,6 +3,7 @@ [ { "id": "osc[1..2]", "x": "0,prevR()+1", "y": 0, "w": "parW()/2", "h": 163, "children": [ + { "id": "Retrig", "r": "parW() - 6", "y": 6, "w": 12, "h": 12 }, { "id": "Pos", "x": 0, "y": 23, "w": 56, "h": 70 }, { "id": "Tune", "x": "prevR()", "y": 23, "w": 56, "h": 70 }, { "id": "Fine", "x": "prevR()", "y": 23, "w": 56, "h": 70 }, @@ -26,6 +27,7 @@ }, { "id": "sub", "x": "prevR()+1", "y": "prevY()", "w": 112, "h": 163, "children": [ + { "id": "Retrig", "r": "parW() - 6", "y": 6, "w": 12, "h": 12 }, { "id": "Wave", "x": 0, "y": 23, "w": 56, "h": 70 }, { "id": "Tune", "x": "prevR()", "y": 23, "w": 56, "h": 70 }, { "id": "Level", "x": 0, "y": "prevB()", "w": 56, "h": 70 }, diff --git a/plugin/Source/Panels.h b/plugin/Source/Panels.h index 0d1c259..697b8b9 100644 --- a/plugin/Source/Panels.h +++ b/plugin/Source/Panels.h @@ -24,6 +24,7 @@ public: addEnable (osc.enable); + addControl (new gin::SVGPluginButton (osc.retrig, gin::Assets::retrigger)); addControl (new gin::Knob (osc.pos)); addControl (new gin::Knob (osc.tune, true)); addControl (new gin::Knob (osc.finetune, true)); @@ -205,6 +206,7 @@ public: addEnable (sub.enable); + addControl (new gin::SVGPluginButton (sub.retrig, gin::Assets::retrigger)); addControl (new gin::Knob (sub.tune, true), 0, 0); addControl (new gin::Knob (sub.level), 1, 0); addControl (new gin::Knob (sub.pan, true), 0, 1); diff --git a/plugin/Source/PluginProcessor.cpp b/plugin/Source/PluginProcessor.cpp index 61a4546..79eb49e 100644 --- a/plugin/Source/PluginProcessor.cpp +++ b/plugin/Source/PluginProcessor.cpp @@ -114,6 +114,7 @@ void WavetableAudioProcessor::OSCParams::setup (WavetableAudioProcessor& p, int juce::String nm = "OSC" + juce::String (idx + 1) + " "; enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, idx == 0 ? 1.0f : 0.0f, 0.0f); + retrig = p.addIntParam (id + "retrig", nm + "Retrig", "Retrig", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0, 0.0f, enableTextFunction); voices = p.addIntParam (id + "unison", nm + "Unison", "Unison", "", { 1.0, 8.0, 1.0, 1.0 }, 1.0, 0.0f); tune = p.addExtParam (id + "tune", nm + "Tune", "Tune", "st", { -36.0, 36.0, 1.0, 1.0 }, 0.0, 0.0f); finetune = p.addExtParam (id + "finetune", nm + "Fine Tune", "Fine", "ct", { -100.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f); @@ -134,7 +135,8 @@ void WavetableAudioProcessor::SubParams::setup (WavetableAudioProcessor& p) juce::String id = "sub"; juce::String nm = "SUB "; - enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f); + enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction); + retrig = p.addIntParam (id + "retrig", nm + "Retrig", "Retrig", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0, 0.0f, enableTextFunction); wave = p.addIntParam (id + "wave", nm + "Wave", "Wave", "", { 0.0, 3.0, 1.0, 1.0 }, 1.0, 0.0f, subTextFunction); tune = p.addExtParam (id + "tune", nm + "Tune", "Tune", "st", { -36.0, 36.0, 1.0, 1.0 }, 0.0, 0.0f); level = p.addExtParam (id + "level", nm + "Level", "Level", "db", { -100.0, 0.0, 1.0, 4.0 }, 0.0, 0.0f); diff --git a/plugin/Source/PluginProcessor.h b/plugin/Source/PluginProcessor.h index a4f336b..692943c 100644 --- a/plugin/Source/PluginProcessor.h +++ b/plugin/Source/PluginProcessor.h @@ -52,7 +52,7 @@ public: { OSCParams() = default; - gin::Parameter::Ptr enable, voices, tune, finetune, level, pos, detune, spread, pan, bend, formant; + gin::Parameter::Ptr enable, voices, tune, finetune, level, pos, detune, spread, pan, bend, formant, retrig; void setup (WavetableAudioProcessor& p, int idx); @@ -63,7 +63,7 @@ public: { SubParams() = default; - gin::Parameter::Ptr enable, wave, tune, level, pan; + gin::Parameter::Ptr enable, wave, tune, level, pan, retrig; void setup (WavetableAudioProcessor& p); diff --git a/plugin/Source/WavetableVoice.cpp b/plugin/Source/WavetableVoice.cpp index 3d3bd95..8c76cde 100644 --- a/plugin/Source/WavetableVoice.cpp +++ b/plugin/Source/WavetableVoice.cpp @@ -51,11 +51,11 @@ void WavetableVoice::noteStarted() updateParams (0); snapParams(); - for (auto& osc : oscillators) - osc.noteOn(); + for (auto idx = 0; auto& osc : oscillators) + osc.noteOn (proc.oscParams[idx++].retrig->getBoolValue() ? 0.0f : proc.rng.nextFloat()); noise.noteOn(); - sub.noteOn(); + sub.noteOn (proc.subParams.retrig->getBoolValue() ? 0.0f : proc.rng.nextFloat()); filterADSR.noteOn();