From 956796adb8bb6a7ec1855afbd5963d268bdeda3a Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sun, 17 Apr 2016 16:32:11 +1000 Subject: Fix ZamGate* metering, and fix initial meter LEDs on comps and gates Signed-off-by: Damien Zammit --- plugins/ZamComp/ZamCompUI.cpp | 2 +- plugins/ZamCompX2/ZamCompX2UI.cpp | 2 +- plugins/ZamGate/ZamGatePlugin.cpp | 14 ++++++--- plugins/ZamGate/ZamGateUI.cpp | 2 +- plugins/ZamGateX2/ZamGateX2Plugin.cpp | 54 +++++++++++++++++------------------ plugins/ZamGateX2/ZamGateX2Plugin.hpp | 2 +- plugins/ZamGateX2/ZamGateX2UI.cpp | 2 +- 7 files changed, 41 insertions(+), 37 deletions(-) diff --git a/plugins/ZamComp/ZamCompUI.cpp b/plugins/ZamComp/ZamCompUI.cpp index fc292fc..6fce7f5 100644 --- a/plugins/ZamComp/ZamCompUI.cpp +++ b/plugins/ZamComp/ZamCompUI.cpp @@ -41,7 +41,7 @@ ZamCompUI::ZamCompUI() // led values fLedRedValue = 0.0f; - fLedYellowValue = 0.0f; + fLedYellowValue = -45.0f; // knob Image knobImage(ZamCompArtwork::knobData, ZamCompArtwork::knobWidth, ZamCompArtwork::knobHeight); diff --git a/plugins/ZamCompX2/ZamCompX2UI.cpp b/plugins/ZamCompX2/ZamCompX2UI.cpp index aee1b6e..9ca9f48 100644 --- a/plugins/ZamCompX2/ZamCompX2UI.cpp +++ b/plugins/ZamCompX2/ZamCompX2UI.cpp @@ -42,7 +42,7 @@ ZamCompX2UI::ZamCompX2UI() // led values fLedRedValue = 0.0f; - fLedYellowValue = 0.0f; + fLedYellowValue = -45.0f; // knob Image knobImage(ZamCompX2Artwork::knobData, ZamCompX2Artwork::knobWidth, ZamCompX2Artwork::knobHeight); diff --git a/plugins/ZamGate/ZamGatePlugin.cpp b/plugins/ZamGate/ZamGatePlugin.cpp index 0d2a042..5afeb3a 100644 --- a/plugins/ZamGate/ZamGatePlugin.cpp +++ b/plugins/ZamGate/ZamGatePlugin.cpp @@ -243,12 +243,17 @@ void ZamGatePlugin::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 in0; + float side; + float max = 0.f; for(i = 0; i < frames; i++) { + in0 = inputs[0][i]; + side = inputs[1][i]; if (usesidechain) { - pushsamplel(samplesl, inputs[1][i]); + pushsamplel(samplesl, side); } else { - pushsamplel(samplesl, inputs[0][i]); + pushsamplel(samplesl, in0); } absample = averageabs(samplesl); if (absample < from_dB(thresdb)) { @@ -263,11 +268,12 @@ void ZamGatePlugin::run(const float** inputs, float** outputs, uint32_t frames) gatestatel = gl; - outputs[0][i] = gl * from_dB(makeup) * inputs[0][i]; + outputs[0][i] = gl * from_dB(makeup) * in0; gainr = (gl > 0) ? sanitize_denormal(-to_dB(gl)) : 40.0; gainr = std::min(gainr, 40.f); - outlevel = (absample > 0) ? to_dB(absample) - thresdb : -60.0; + max = (fabsf(outputs[0][i]) > max) ? fabsf(outputs[0][i]) : sanitize_denormal(max); } + outlevel = (max == 0.f) ? -45.f : to_dB(max); } // ----------------------------------------------------------------------- diff --git a/plugins/ZamGate/ZamGateUI.cpp b/plugins/ZamGate/ZamGateUI.cpp index 15f89cc..97682ca 100644 --- a/plugins/ZamGate/ZamGateUI.cpp +++ b/plugins/ZamGate/ZamGateUI.cpp @@ -40,7 +40,7 @@ ZamGateUI::ZamGateUI() // led values fLedRedValue = 0.0f; - fLedYellowValue = 0.0f; + fLedYellowValue = -45.0f; // knob Image knobImage(ZamGateArtwork::knobData, ZamGateArtwork::knobWidth, ZamGateArtwork::knobHeight); diff --git a/plugins/ZamGateX2/ZamGateX2Plugin.cpp b/plugins/ZamGateX2/ZamGateX2Plugin.cpp index a342c39..9bc58f9 100644 --- a/plugins/ZamGateX2/ZamGateX2Plugin.cpp +++ b/plugins/ZamGateX2/ZamGateX2Plugin.cpp @@ -203,8 +203,7 @@ void ZamGateX2Plugin::loadProgram(uint32_t index) void ZamGateX2Plugin::activate() { int i; - gatestatel = 0.f; - gatestater = 0.f; + gatestate = 0.f; posl = 0; posr = 0; for (i = 0; i < MAX_GATE; i++) { @@ -247,53 +246,52 @@ void ZamGateX2Plugin::run(const float** inputs, float** outputs, uint32_t frames float absamplel, absampler, absample; float att; float rel; - float gl, gr; + float g; float ming; float fs; + float in0; + float in1; + float side; + float max; fs = getSampleRate(); - gl = gatestatel; - gr = gatestater; + g = gatestate; att = 1000.f / (attack * fs); rel = 1000.f / (release * fs); bool usesidechain = (sidechain < 0.5) ? false : true; + max = 0.f; for(i = 0; i < frames; i++) { + in0 = inputs[0][i]; + in1 = inputs[1][i]; + side = inputs[2][i]; if (usesidechain) { - pushsamplel(samplesl, inputs[2][i]); + pushsamplel(samplesl, side); absample = averageabs(samplesl); } else { - pushsamplel(samplesl, inputs[0][i]); - pushsampler(samplesr, inputs[1][i]); + pushsamplel(samplesl, in0); + pushsampler(samplesr, in1); absamplel = averageabs(samplesl); absampler = averageabs(samplesr); absample = std::max(absamplel, absampler); } if (absample < from_dB(thresdb)) { - gr -= rel; - if (gr < 0.f) - gr = 0.f; - gl -= rel; - if (gl < 0.f) - gl = 0.f; + g -= rel; + if (g < 0.f) + g = 0.f; } else { - gr += att; - if (gr > 1.f) - gr = 1.f; - gl += att; - if (gl > 1.f) - gl = 1.f; + g += att; + if (g > 1.f) + g = 1.f; } - gatestatel = gl; - gatestater = gr; + gatestate = g; - outputs[0][i] = gl * from_dB(makeup) * inputs[0][i]; - outputs[1][i] = gr * from_dB(makeup) * inputs[1][i]; - ming = std::max(gr, gl); - gainr = (ming > 0) ? sanitize_denormal(-to_dB(ming)) : 40.0; - gainr = std::min(gainr, 40.f); - outlevel = (absample > 0) ? to_dB(absample) - thresdb : -60.0; + outputs[0][i] = g * from_dB(makeup) * in0; + outputs[1][i] = g * from_dB(makeup) * in1; + gainr = (g > 0) ? sanitize_denormal(-to_dB(g)) : 45.0; + max = (fabsf(fmaxf(outputs[0][i], outputs[1][i])) > max) ? fabsf(fmaxf(outputs[0][i], outputs[1][i])) : sanitize_denormal(max); } + outlevel = (max == 0.f) ? -45.f : to_dB(max); } // ----------------------------------------------------------------------- diff --git a/plugins/ZamGateX2/ZamGateX2Plugin.hpp b/plugins/ZamGateX2/ZamGateX2Plugin.hpp index 97cacf5..6a0977f 100644 --- a/plugins/ZamGateX2/ZamGateX2Plugin.hpp +++ b/plugins/ZamGateX2/ZamGateX2Plugin.hpp @@ -127,7 +127,7 @@ protected: float samplesl[MAX_GATE]; float samplesr[MAX_GATE]; - float gatestatel, gatestater; + float gatestate; int posl, posr; }; diff --git a/plugins/ZamGateX2/ZamGateX2UI.cpp b/plugins/ZamGateX2/ZamGateX2UI.cpp index 92b02c4..fe3fa87 100644 --- a/plugins/ZamGateX2/ZamGateX2UI.cpp +++ b/plugins/ZamGateX2/ZamGateX2UI.cpp @@ -40,7 +40,7 @@ ZamGateX2UI::ZamGateX2UI() // led values fLedRedValue = 0.0f; - fLedYellowValue = 0.0f; + fLedYellowValue = -45.0f; // knob Image knobImage(ZamGateX2Artwork::knobData, ZamGateX2Artwork::knobWidth, ZamGateX2Artwork::knobHeight); -- cgit v1.2.3