diff options
author | Damien Zammit <damien@zamaudio.com> | 2016-04-17 00:05:15 +1000 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2016-04-17 00:05:15 +1000 |
commit | f0fa09ddf2fde13226912df295fd602f56f63415 (patch) | |
tree | 57550aba90b1b79983daae229d9eccaca08a705b | |
parent | e3831c6564190e042489324b5774897273096123 (diff) |
Made ratio on comps logarithmic and fixed metering
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r-- | plugins/ZamComp/ZamCompPlugin.cpp | 21 | ||||
-rw-r--r-- | plugins/ZamComp/ZamCompUI.cpp | 1 | ||||
-rw-r--r-- | plugins/ZamCompX2/ZamCompX2Plugin.cpp | 23 | ||||
-rw-r--r-- | plugins/ZamCompX2/ZamCompX2UI.cpp | 1 |
4 files changed, 27 insertions, 19 deletions
diff --git a/plugins/ZamComp/ZamCompPlugin.cpp b/plugins/ZamComp/ZamCompPlugin.cpp index df40dc0..be48bcc 100644 --- a/plugins/ZamComp/ZamCompPlugin.cpp +++ b/plugins/ZamComp/ZamCompPlugin.cpp @@ -63,7 +63,7 @@ void ZamCompPlugin::initParameter(uint32_t index, Parameter& parameter) parameter.ranges.max = 8.0f; break; case paramRatio: - parameter.hints = kParameterIsAutomable; + parameter.hints = kParameterIsAutomable | kParameterIsLogarithmic; parameter.name = "Ratio"; parameter.symbol = "rat"; parameter.unit = " "; @@ -300,23 +300,24 @@ void ZamCompPlugin::run(const float** inputs, float** outputs, uint32_t frames) int relslew = 0; float max = 0.f; float lgaininp = 0.f; - float rgaininp = 0.f; float Lgain = 1.f; float Rgain = 1.f; float Lxg, Lxl, Lyg, Lyl, Ly1; float checkwidth = 0.f; bool usesidechain = (sidechain < 0.5) ? false : true; uint32_t i; + float ingain; + float in0; + float in1; for (i = 0; i < frames; i++) { - relslew = 0; + in0 = inputs[0][i]; + in1 = inputs[1][i]; + ingain = usesidechain ? in1 : in0; + relslew = 0; attslew = 0; Lyg = 0.f; - if (usesidechain) { - Lxg = (inputs[1][i]==0.f) ? -160.f : to_dB(fabs(inputs[1][i])); - } else { - Lxg = (inputs[0][i]==0.f) ? -160.f : to_dB(fabs(inputs[0][i])); - } + Lxg = (ingain==0.f) ? -160.f : to_dB(fabs(ingain)); Lxg = sanitize_denormal(Lxg); Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width); @@ -357,10 +358,10 @@ void ZamCompPlugin::run(const float** inputs, float** outputs, uint32_t frames) gainred = Lyl; - lgaininp = inputs[0][i] * Lgain; + lgaininp = in0 * Lgain; outputs[0][i] = lgaininp * from_dB(makeup); - max = (fabsf(lgaininp) > max) ? fabsf(lgaininp) : sanitize_denormal(max); + max = (fabsf(in0) > max) ? fabsf(in0) : sanitize_denormal(max); oldL_yl = Lyl; oldL_y1 = Ly1; diff --git a/plugins/ZamComp/ZamCompUI.cpp b/plugins/ZamComp/ZamCompUI.cpp index 7d1f59f..fc292fc 100644 --- a/plugins/ZamComp/ZamCompUI.cpp +++ b/plugins/ZamComp/ZamCompUI.cpp @@ -76,6 +76,7 @@ ZamCompUI::ZamCompUI() fKnobRatio->setAbsolutePos(270, 45); fKnobRatio->setId(ZamCompPlugin::paramRatio); fKnobRatio->setRange(1.0f, 20.0f); + fKnobRatio->setUsingLogScale(true); fKnobRatio->setDefault(4.0f); fKnobRatio->setRotationAngle(240); fKnobRatio->setCallback(this); diff --git a/plugins/ZamCompX2/ZamCompX2Plugin.cpp b/plugins/ZamCompX2/ZamCompX2Plugin.cpp index 5e2b872..17ba0fc 100644 --- a/plugins/ZamCompX2/ZamCompX2Plugin.cpp +++ b/plugins/ZamCompX2/ZamCompX2Plugin.cpp @@ -63,7 +63,7 @@ void ZamCompX2Plugin::initParameter(uint32_t index, Parameter& parameter) parameter.ranges.max = 8.0f; break; case paramRatio: - parameter.hints = kParameterIsAutomable; + parameter.hints = kParameterIsAutomable | kParameterIsLogarithmic; parameter.name = "Ratio"; parameter.symbol = "rat"; parameter.unit = " "; @@ -327,17 +327,23 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames float Rxg, Rxl, Ryg, Ryl, Ry1; float checkwidth = 0.f; uint32_t i; + float in0; + float in1; + float ingain; for (i = 0; i < frames; i++) { - relslew = 0; + in0 = inputs[0][i]; + in1 = inputs[1][i]; + ingain = usesidechain ? inputs[2][i] : fmaxf(in0, in1); + relslew = 0; attslew = 0; Lyg = Ryg = 0.f; if (usesidechain) { - Lxg = (inputs[2][i]==0.f) ? -160.f : to_dB(fabs(inputs[2][i])); + Lxg = (ingain==0.f) ? -160.f : to_dB(fabs(ingain)); Rxg = Lxg; } else { - Lxg = (inputs[0][i]==0.f) ? -160.f : to_dB(fabs(inputs[0][i])); - Rxg = (inputs[1][i]==0.f) ? -160.f : to_dB(fabs(inputs[1][i])); + Lxg = (in0==0.f) ? -160.f : to_dB(fabs(in1)); + Rxg = (in1==0.f) ? -160.f : to_dB(fabs(in1)); } Lxg = sanitize_denormal(Lxg); Rxg = sanitize_denormal(Rxg); @@ -416,13 +422,12 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames cdb = -Ryl; Rgain = from_dB(cdb); - lgaininp = inputs[0][i] * Lgain; - rgaininp = inputs[1][i] * Rgain; + lgaininp = in0 * Lgain; + rgaininp = in1 * Rgain; outputs[0][i] = lgaininp * from_dB(makeup); outputs[1][i] = rgaininp * from_dB(makeup); - max = (fabsf(lgaininp) > max) ? fabsf(lgaininp) : sanitize_denormal(max); - max = (fabsf(rgaininp) > max) ? fabsf(rgaininp) : sanitize_denormal(max); + max = (fabsf(fmaxf(in0,in1)) > max) ? fabsf(fmaxf(in0,in1)) : sanitize_denormal(max); oldL_yl = Lyl; oldR_yl = Ryl; diff --git a/plugins/ZamCompX2/ZamCompX2UI.cpp b/plugins/ZamCompX2/ZamCompX2UI.cpp index 7c3d2ff..aee1b6e 100644 --- a/plugins/ZamCompX2/ZamCompX2UI.cpp +++ b/plugins/ZamCompX2/ZamCompX2UI.cpp @@ -77,6 +77,7 @@ ZamCompX2UI::ZamCompX2UI() fKnobRatio->setAbsolutePos(270, 45); fKnobRatio->setId(ZamCompX2Plugin::paramRatio); fKnobRatio->setRange(1.0f, 20.0f); + fKnobRatio->setUsingLogScale(true); fKnobRatio->setDefault(4.0f); fKnobRatio->setRotationAngle(240); fKnobRatio->setCallback(this); |