[SCM] calf/master: + Compressor: move non-time-critical parts to modules_dsp.cpp, add activation flag

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


The following commit has been merged in the master branch:
commit 1ad9ec98cb358d2f7aea1cbe3efe5274b5194bb6
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Mon Nov 17 20:45:03 2008 +0000

    + Compressor: move non-time-critical parts to modules_dsp.cpp, add activation flag

diff --git a/src/calf/modules.h b/src/calf/modules.h
index 6a27255..c839661 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -706,11 +706,10 @@ public:
     float *outs[out_count];
     float *params[param_count];
     uint32_t srate;
-    void activate() {
-        linslope = 0.f;
-        peak = 0.f;
-        clip = 0.f;
-    }
+    bool is_active;
+    compressor_audio_module();
+    void activate();
+    void deactivate();
     uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
         bool bypass = *params[param_bypass] > 0.5f;
         bool rms = *params[param_detection] == 0;
@@ -814,11 +813,7 @@ public:
         return inputs_mask;
     }
 
-    void set_sample_rate(uint32_t sr) {
-            srate = sr;
-            awL.set(sr);
-            awR.set(sr);
-    }
+    void set_sample_rate(uint32_t sr);
     inline float output_level(float slope)
     {
         float threshold = *params[param_threshold];
@@ -842,29 +837,8 @@ public:
         }
         return slope * makeup;
     }
-    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context) { 
-        if (subindex > 0) // 1
-            return false;
-        for (int i = 0; i < points; i++)
-        {
-            float input = pow(65536.0, i * 1.0 / (points - 1) - 1);
-            float output = output_level(input);
-            //if (subindex == 0)
-            //    data[i] = 1 + 2 * log(input) / log(65536);
-            //else
-            data[i] = 1 + 2 * log(output) / log(65536);
-        }
-        return true;
-    }
-    virtual bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context) {
-        if (!subindex)
-        {
-            x = 1 + log(detected) / log(65536);
-            y = 1 + 2 * log(output_level(detected)) / log(65536);
-            return true;
-        }
-        return false;
-    }
+    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
+    virtual bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context);
 };
 
 extern std::string get_builtin_modules_rdf();
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index c4381d4..515e874 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -317,3 +317,63 @@ float multichorus_audio_module::freq_gain(int subindex, float freq, float srate)
 {
     return (subindex ? right : left).freq_gain(freq, srate);                
 }
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+compressor_audio_module::compressor_audio_module()
+{
+    is_active = false;
+    srate = 0;
+}
+
+void compressor_audio_module::activate()
+{
+    is_active = true;
+    linslope = 0.f;
+    peak = 0.f;
+    clip = 0.f;
+}
+
+void compressor_audio_module::deactivate()
+{
+    is_active = false;
+}
+
+void compressor_audio_module::set_sample_rate(uint32_t sr)
+{
+    srate = sr;
+    awL.set(sr);
+    awR.set(sr);
+}
+
+bool compressor_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
+{ 
+    if (!is_active)
+        return false;
+    if (subindex > 0) // 1
+        return false;
+    for (int i = 0; i < points; i++)
+    {
+        float input = pow(65536.0, i * 1.0 / (points - 1) - 1);
+        float output = output_level(input);
+        //if (subindex == 0)
+        //    data[i] = 1 + 2 * log(input) / log(65536);
+        //else
+        data[i] = 1 + 2 * log(output) / log(65536);
+    }
+    return true;
+}
+
+bool compressor_audio_module::get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context)
+{
+    if (!is_active)
+        return false;
+    if (!subindex)
+    {
+        x = 1 + log(detected) / log(65536);
+        y = 1 + 2 * log(output_level(detected)) / log(65536);
+        return true;
+    }
+    return false;
+}
+

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list