Skip to content

Commit

Permalink
Added retrig to ADSRs
Browse files Browse the repository at this point in the history
  • Loading branch information
FigBug committed Oct 7, 2023
1 parent 2190db8 commit bd58bd1
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 53 deletions.
2 changes: 2 additions & 0 deletions Changelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.11
1.0.12
9 changes: 6 additions & 3 deletions plugin/Resources/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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":
[
Expand All @@ -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":
[
Expand Down
70 changes: 44 additions & 26 deletions plugin/Source/Panels.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,24 @@ class ADSRBox : public gin::ParamBox
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;
};

//==============================================================================
Expand All @@ -290,13 +303,13 @@ class FilterBox : public gin::ParamBox
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);
Expand Down Expand Up @@ -333,8 +346,11 @@ class FilterBox : public gin::ParamBox
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
Expand All @@ -349,11 +365,16 @@ class FilterBox : public gin::ParamBox
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";
Expand Down Expand Up @@ -407,13 +428,11 @@ class LFOBox : public gin::ParamBox
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
Expand Down Expand Up @@ -472,11 +491,22 @@ class ENVBox : public gin::ParamBox
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;
};

Expand Down Expand Up @@ -519,8 +549,6 @@ class StepBox : public gin::ParamBox
addControl (g, 0, 0, 4, 1);

addControl (new gin::SVGPluginButton (prs.retrig, gin::Assets::retrigger));

setSize (112, 163);
}

WavetableAudioProcessor& proc;
Expand Down Expand Up @@ -618,8 +646,6 @@ class GateBox : public gin::ParamBox
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;
Expand All @@ -642,8 +668,6 @@ class ChorusBox : public gin::ParamBox

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;
Expand All @@ -661,8 +685,6 @@ class DistortBox : public gin::ParamBox
addEnable (proc.distortionParams.enable);

addControl (new gin::Knob (proc.distortionParams.amount), 0, 0);

setSize (112, 163);
}

WavetableAudioProcessor& proc;
Expand Down Expand Up @@ -691,8 +713,6 @@ class DelayBox : public gin::ParamBox
b->setName ("Delay2");

watchParam (proc.delayParams.sync);

setSize (168, 163);
}

void paramChanged () override
Expand Down Expand Up @@ -724,8 +744,6 @@ class ReverbBox : public gin::ParamBox
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;
Expand Down
35 changes: 19 additions & 16 deletions plugin/Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions plugin/Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class WavetableAudioProcessor : public gin::Processor,
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);
Expand All @@ -98,7 +98,7 @@ class WavetableAudioProcessor : public gin::Processor,
{
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);

Expand Down Expand Up @@ -132,7 +132,7 @@ class WavetableAudioProcessor : public gin::Processor,
{
ADSRParams() = default;

gin::Parameter::Ptr attack, decay, sustain, release, velocityTracking;
gin::Parameter::Ptr attack, decay, sustain, release, velocityTracking, retrig;

void setup (WavetableAudioProcessor& p);

Expand Down
11 changes: 7 additions & 4 deletions plugin/Source/WavetableVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bd58bd1

Please sign in to comment.