Skip to content

Commit

Permalink
Add max gate close knob to ZamGate*
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Zammit <damien@zamaudio.com>
  • Loading branch information
zamaudio committed Apr 19, 2016
1 parent b18d78c commit fa60d65
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 10 deletions.
21 changes: 19 additions & 2 deletions plugins/ZamGate/ZamGatePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ void ZamGatePlugin::initParameter(uint32_t index, Parameter& parameter)
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramGateclose:
parameter.hints = kParameterIsAutomable;
parameter.name = "Max gate close";
parameter.symbol = "close";
parameter.unit = "dB";
parameter.ranges.def = -50.0f;
parameter.ranges.min = -50.0f;
parameter.ranges.max = 0.0f;
break;
case paramGainR:
parameter.hints = kParameterIsOutput;
parameter.name = "Gain Reduction";
Expand Down Expand Up @@ -145,6 +154,9 @@ float ZamGatePlugin::getParameterValue(uint32_t index) const
case paramSidechain:
return sidechain;
break;
case paramGateclose:
return gateclose;
break;
case paramGainR:
return gainr;
break;
Expand Down Expand Up @@ -175,6 +187,9 @@ void ZamGatePlugin::setParameterValue(uint32_t index, float value)
case paramSidechain:
sidechain = value;
break;
case paramGateclose:
gateclose = value;
break;
case paramGainR:
gainr = value;
break;
Expand All @@ -192,6 +207,7 @@ void ZamGatePlugin::loadProgram(uint32_t index)
gainr = 0.0;
makeup = 0.0;
sidechain = 0.0;
gateclose = -50.f;
outlevel = -45.0;
activate();
}
Expand Down Expand Up @@ -246,6 +262,7 @@ void ZamGatePlugin::run(const float** inputs, float** outputs, uint32_t frames)
float in0;
float side;
float max = 0.f;
float mingate = (gateclose == -50.f) ? 0.f : from_dB(gateclose);

for(i = 0; i < frames; i++) {
in0 = inputs[0][i];
Expand All @@ -258,8 +275,8 @@ void ZamGatePlugin::run(const float** inputs, float** outputs, uint32_t frames)
absample = averageabs(samplesl);
if (absample < from_dB(thresdb)) {
gl -= rel;
if (gl < 0.f)
gl = 0.f;
if (gl < mingate)
gl = mingate;
} else {
gl += att;
if (gl > 1.f)
Expand Down
5 changes: 3 additions & 2 deletions plugins/ZamGate/ZamGatePlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ZamGatePlugin : public Plugin
paramThresh,
paramMakeup,
paramSidechain,
paramGateclose,
paramOutputLevel,
paramGainR,
paramCount
Expand Down Expand Up @@ -75,7 +76,7 @@ class ZamGatePlugin : public Plugin

uint32_t getVersion() const noexcept override
{
return d_version(3, 6, 1);
return d_version(3, 6, 2);
}

int64_t getUniqueId() const noexcept override
Expand Down Expand Up @@ -119,7 +120,7 @@ class ZamGatePlugin : public Plugin
}

// -------------------------------------------------------------------
float attack,release,thresdb,makeup,sidechain,gainr,outlevel; //parameters
float attack,release,thresdb,makeup,sidechain,gateclose,gainr,outlevel; //parameters

void pushsamplel(float samples[], float sample);
float averageabs(float samples[]);
Expand Down
12 changes: 12 additions & 0 deletions plugins/ZamGate/ZamGateUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ ZamGateUI::ZamGateUI()
fKnobMakeup->setRotationAngle(240);
fKnobMakeup->setCallback(this);

fKnobGateclose = new ImageKnob(this, knobImage);
fKnobGateclose->setAbsolutePos(480, 62);
fKnobGateclose->setId(ZamGatePlugin::paramGateclose);
fKnobGateclose->setRange(-50.0f, 0.0f);
fKnobGateclose->setDefault(-50.0f);
fKnobGateclose->setRotationAngle(240);
fKnobGateclose->setCallback(this);

fToggleSidechain = new ImageSwitch(this, fTogOff, fTogOn);
fToggleSidechain->setAbsolutePos(350, 61);
fToggleSidechain->setId(ZamGatePlugin::paramSidechain);
Expand Down Expand Up @@ -106,6 +114,9 @@ void ZamGateUI::parameterChanged(uint32_t index, float value)
case ZamGatePlugin::paramMakeup:
fKnobMakeup->setValue(value);
break;
case ZamGatePlugin::paramGateclose:
fKnobGateclose->setValue(value);
break;
case ZamGatePlugin::paramSidechain:
fToggleSidechain->setDown(value > 0.5);
break;
Expand Down Expand Up @@ -133,6 +144,7 @@ void ZamGateUI::programLoaded(uint32_t index)
fKnobRelease->setValue(100.0f);
fKnobThresh->setValue(-60.0f);
fKnobMakeup->setValue(0.0f);
fKnobGateclose->setValue(-50.0f);
fToggleSidechain->setDown(false);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/ZamGate/ZamGateUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ZamGateUI : public UI,
private:
Image fImgBackground;
ScopedPointer<ImageKnob> fKnobAttack, fKnobRelease, fKnobThresh;
ScopedPointer<ImageKnob> fKnobMakeup;
ScopedPointer<ImageKnob> fKnobMakeup, fKnobGateclose;
ScopedPointer<ImageSwitch> fToggleSidechain;

Image fLedRedImg;
Expand Down
21 changes: 19 additions & 2 deletions plugins/ZamGateX2/ZamGateX2Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ void ZamGateX2Plugin::initParameter(uint32_t index, Parameter& parameter)
parameter.ranges.min = -30.0f;
parameter.ranges.max = 30.0f;
break;
case paramGateclose:
parameter.hints = kParameterIsAutomable;
parameter.name = "Max gate close";
parameter.symbol = "close";
parameter.unit = "dB";
parameter.ranges.def = -50.0f;
parameter.ranges.min = -50.0f;
parameter.ranges.max = 0.0f;
break;
case paramSidechain:
parameter.hints = kParameterIsAutomable | kParameterIsBoolean;
parameter.name = "Sidechain";
Expand Down Expand Up @@ -142,6 +151,9 @@ float ZamGateX2Plugin::getParameterValue(uint32_t index) const
case paramMakeup:
return makeup;
break;
case paramGateclose:
return gateclose;
break;
case paramSidechain:
return sidechain;
break;
Expand Down Expand Up @@ -172,6 +184,9 @@ void ZamGateX2Plugin::setParameterValue(uint32_t index, float value)
case paramMakeup:
makeup = value;
break;
case paramGateclose:
gateclose = value;
break;
case paramSidechain:
sidechain = value;
break;
Expand All @@ -192,6 +207,7 @@ void ZamGateX2Plugin::loadProgram(uint32_t index)
gainr = 0.0;
makeup = 0.0;
outlevel = -45.0;
gateclose = -50.0;
sidechain = 0.0;

activate();
Expand Down Expand Up @@ -258,6 +274,7 @@ void ZamGateX2Plugin::run(const float** inputs, float** outputs, uint32_t frames
att = 1000.f / (attack * fs);
rel = 1000.f / (release * fs);
bool usesidechain = (sidechain < 0.5) ? false : true;
float mingate = (gateclose == -50.f) ? 0.f : from_dB(gateclose);
max = 0.f;

for(i = 0; i < frames; i++) {
Expand All @@ -276,8 +293,8 @@ void ZamGateX2Plugin::run(const float** inputs, float** outputs, uint32_t frames
}
if (absample < from_dB(thresdb)) {
g -= rel;
if (g < 0.f)
g = 0.f;
if (g < mingate)
g = mingate;
} else {
g += att;
if (g > 1.f)
Expand Down
5 changes: 3 additions & 2 deletions plugins/ZamGateX2/ZamGateX2Plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ZamGateX2Plugin : public Plugin
paramThresh,
paramMakeup,
paramSidechain,
paramGateclose,
paramOutputLevel,
paramGainR,
paramCount
Expand Down Expand Up @@ -75,7 +76,7 @@ class ZamGateX2Plugin : public Plugin

uint32_t getVersion() const noexcept override
{
return d_version(3, 6, 1);
return d_version(3, 6, 2);
}

int64_t getUniqueId() const noexcept override
Expand Down Expand Up @@ -119,7 +120,7 @@ class ZamGateX2Plugin : public Plugin
}

// -------------------------------------------------------------------
float attack,release,thresdb,makeup,sidechain,gainr,outlevel; //parameters
float attack,release,thresdb,makeup,gateclose,sidechain,gainr,outlevel; //parameters

void pushsamplel(float samples[], float sample);
void pushsampler(float samples[], float sample);
Expand Down
12 changes: 12 additions & 0 deletions plugins/ZamGateX2/ZamGateX2UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ ZamGateX2UI::ZamGateX2UI()
fKnobMakeup->setRotationAngle(240);
fKnobMakeup->setCallback(this);

fKnobGateclose = new ImageKnob(this, knobImage);
fKnobGateclose->setAbsolutePos(480, 61);
fKnobGateclose->setId(ZamGateX2Plugin::paramGateclose);
fKnobGateclose->setRange(-50.0f, 0.0f);
fKnobGateclose->setDefault(-50.0f);
fKnobGateclose->setRotationAngle(240);
fKnobGateclose->setCallback(this);

fToggleSidechain = new ImageSwitch(this, fTogOff, fTogOn);
fToggleSidechain->setAbsolutePos(350, 61);
fToggleSidechain->setId(ZamGateX2Plugin::paramSidechain);
Expand Down Expand Up @@ -106,6 +114,9 @@ void ZamGateX2UI::parameterChanged(uint32_t index, float value)
case ZamGateX2Plugin::paramMakeup:
fKnobMakeup->setValue(value);
break;
case ZamGateX2Plugin::paramGateclose:
fKnobGateclose->setValue(value);
break;
case ZamGateX2Plugin::paramSidechain:
fToggleSidechain->setDown(value > 0.5);
break;
Expand Down Expand Up @@ -133,6 +144,7 @@ void ZamGateX2UI::programLoaded(uint32_t index)
fKnobRelease->setValue(100.0f);
fKnobThresh->setValue(-60.0f);
fKnobMakeup->setValue(0.0f);
fKnobGateclose->setValue(-50.0f);
fToggleSidechain->setDown(false);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/ZamGateX2/ZamGateX2UI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ZamGateX2UI : public UI,
private:
Image fImgBackground;
ScopedPointer<ImageKnob> fKnobAttack, fKnobRelease, fKnobThresh;
ScopedPointer<ImageKnob> fKnobMakeup;
ScopedPointer<ImageKnob> fKnobMakeup, fKnobGateclose;
ScopedPointer<ImageSwitch> fToggleSidechain;

Image fLedRedImg;
Expand Down

0 comments on commit fa60d65

Please sign in to comment.