[SCM] calf/master: + Compressor: Can now expand 4:1, operates 100% log scale. :)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:38:38 UTC 2013


The following commit has been merged in the master branch:
commit bcf3f19dd176576763342c9acf31f9c72f9a872f
Author: Thor Harald Johansen <thj at thj.no>
Date:   Wed Nov 26 01:27:14 2008 +0100

    + Compressor: Can now expand 4:1, operates 100% log scale. :)

diff --git a/gui/gui-compressor.xml b/gui/gui-compressor.xml
index bd3425b..4806de6 100644
--- a/gui/gui-compressor.xml
+++ b/gui/gui-compressor.xml
@@ -18,7 +18,7 @@
         </vbox>
     </hbox>
     <if cond="directlink">
-        <line-graph attach-x="0" attach-y="1" refresh="1" width="160" height="160" param="compression" square="1" expand-y="1" fill-y="1"/>
+        <line-graph attach-x="0" attach-y="1" refresh="1" width="384" height="384" param="compression" square="1" expand-y="1" fill-y="1"/>
     </if>
     <table attach-x="0" attach-y="2" expand-y="0" expand-x="1" spacing="10" rows="1" cols="3">
         <vbox expand-x="1" fill-x="1" expand="1" fill="1" attach-x="0" attach-y="0">
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 7572e29..d8f4335 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -97,7 +97,7 @@ struct monosynth_metadata: public plugin_metadata<monosynth_metadata>
 struct compressor_metadata: public plugin_metadata<compressor_metadata>
 {
     enum { in_count = 2, out_count = 2, support_midi = false, require_midi = false, rt_capable = true };
-    enum { param_threshold, param_ratio, param_attack, param_release, param_makeup, param_knee, param_detection, param_stereo_link, param_aweighting, param_compression, param_peak, param_clip, param_bypass, param_logarithmic, param_count };
+    enum { param_threshold, param_ratio, param_attack, param_release, param_makeup, param_knee, param_detection, param_stereo_link, param_aweighting, param_compression, param_peak, param_clip, param_bypass, param_count };
     PLUGIN_NAME_ID_LABEL("compressor", "compressor", "Compressor")
 };
 
diff --git a/src/calf/modules.h b/src/calf/modules.h
index b3ddb43..adc5df0 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -711,21 +711,14 @@ public:
         float release_coeff = std::min(1.f, 1.f / (release * srate / 4000.f));
         makeup = *params[param_makeup];
         knee = *params[param_knee];
-        logarithmic = *params[param_logarithmic] > 0.5f;
 
         float linKneeSqrt = sqrt(knee);
         float linKneeStart = linThreshold / linKneeSqrt;
         float linKneeStop = linThreshold * linKneeSqrt;
         
-        if(logarithmic) {
-            threshold = linThreshold > 0.f ? log(linThreshold) / log(2) : 0.f;
-            kneeStart = linKneeStart > 0.f ? log(linKneeStart) / log(2) : 0.f;
-            kneeStop = linKneeStop > 0.f ? log(linKneeStop) / log(2) : 0.f;
-        } else {
-            threshold = linThreshold;
-            kneeStart = linKneeStart;
-            kneeStop = linKneeStop;
-        }
+        threshold = lin2log(linThreshold);
+        kneeStart = lin2log(linKneeStart);
+        kneeStop = lin2log(linKneeStop);
 
         numsamples += offset;
         
@@ -809,17 +802,16 @@ public:
         return inputs_mask;
     }
 
+    inline float lin2log(float x) {
+        return x > 0.f ? log(x) / log(2.f) : 0.f;
+    }
+
     inline float output_level(float slope) {
         return output_gain(slope) * makeup;
     }
     
     inline float output_gain(float linSlope) {
-         float slope;
-         if(logarithmic) {
-            slope = linSlope > 0.f ? log(linSlope) / log(2) : 0;
-         } else {
-            slope = linSlope;
-         }
+         float slope = lin2log(linSlope);
 
          if(slope > kneeStart) {
             float gain = 0.f;
@@ -836,11 +828,7 @@ public:
                 gain = hermite_interpolation(slope, kneeStart, kneeStop, kneeStart, (kneeStop - threshold) / ratio + threshold, 1.f, delta);
             }
             
-            if(logarithmic) {
-                return pow(2, gain);
-            } else {
-                return gain;
-            }
+            return pow(2, gain);
         }
 
         return linSlope;
diff --git a/src/modules.cpp b/src/modules.cpp
index 96f2b19..66a282d 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -178,7 +178,7 @@ const char *compressor_stereo_link_names[] = { "Average", "Maximum" };
 
 CALF_PORT_PROPS(compressor) = {
     { 0.0625,      0, 1,    0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "threshold", "Threshold" },
-    { 5,      1, 100,  101, PF_FLOAT | PF_SCALE_LOG_INF | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "ratio", "Ratio" },
+    { 5,      0.25, 20,  21, PF_FLOAT | PF_SCALE_LOG_INF | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "ratio", "Ratio" },
     { 15,     0.01, 2000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "attack", "Attack" },
     { 150,    0.01, 2000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "release", "Release" },
     { 2,      1, 16,   0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "makeup", "Makeup Gain" },
@@ -189,8 +189,7 @@ CALF_PORT_PROPS(compressor) = {
     { 0, 0.03125, 1,    0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_CTLO_REVERSE | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL| PF_PROP_GRAPH, NULL, "compression", "Compression" },
     { 0,      0,  1,    0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "peak", "Peak" },
     { 0,      0,  1,    0, PF_BOOL | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip", "Clip" },
-    { 0,      0,  1,    0, PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
-    { 1,      0,  1,    0, PF_BOOL | PF_CTL_TOGGLE, NULL, "logarithmic", "Logarithmic" }
+    { 0,      0,  1,    0, PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" }
 };
 
 CALF_PLUGIN_INFO(compressor) = { 0x8502, "Compressor", "Calf Compressor", "Thor Harald Johansen", calf_plugins::calf_copyright_info, "CompressorPlugin" };

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list