[SCM] calf/master: + Compressor - move to moduels.h for now

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


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

    + Compressor - move to moduels.h for now

diff --git a/src/calf/modules.h b/src/calf/modules.h
index 8e9b681..6a27255 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -28,6 +28,7 @@
 #include "multichorus.h"
 #include "giface.h"
 #include "metadata.h"
+#include "loudness.h"
 
 namespace calf_plugins {
 
@@ -694,6 +695,178 @@ public:
     bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
 };
 
+class compressor_audio_module: public audio_module<compressor_metadata>, public line_graph_iface {
+private:
+    float linslope, clip, peak, detected;
+    bool aweighting;
+    aweighter awL, awR;
+public:
+
+    float *ins[in_count];
+    float *outs[out_count];
+    float *params[param_count];
+    uint32_t srate;
+    void activate() {
+        linslope = 0.f;
+        peak = 0.f;
+        clip = 0.f;
+    }
+    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;
+        bool average = *params[param_stereo_link] == 0;
+        aweighting = *params[param_aweighting] > 0.5f;
+        float threshold = *params[param_threshold];
+        float ratio = *params[param_ratio];
+        float attack = *params[param_attack];
+        float attack_coeff = std::min(1.f, 1.f / (attack * srate / 4000.f));
+        float release = *params[param_release];
+        float release_coeff = std::min(1.f, 1.f / (release * srate / 4000.f));
+        float makeup = *params[param_makeup];
+        float knee = *params[param_knee];
+
+        numsamples += offset;
+        
+        if(bypass) {
+            int count = numsamples * sizeof(float);
+            memcpy(outs[0], ins[0], count);
+            memcpy(outs[1], ins[1], count);
+
+            if(params[param_compression] != NULL) {
+                *params[param_compression] = 1.f;
+            }
+
+            if(params[param_clip] != NULL) {
+                *params[param_clip] = 0.f;
+            }
+
+            if(params[param_peak] != NULL) {
+                *params[param_peak] = 0.f;
+            }
+      
+            return inputs_mask;
+        }
+
+        float gain = 1.f;
+        
+        while(offset < numsamples) {
+            float left = ins[0][offset];
+            float right = ins[1][offset];
+            if(aweighting) {
+                left = awL.process(left);
+                right = awR.process(right);
+            }
+            float absample = average ? (fabs(left) + fabs(right)) / 2 : std::max(fabs(left), fabs(right));
+            if(rms) absample *= absample;
+            linslope += (absample - linslope) * (absample > linslope ? attack_coeff : release_coeff);
+            float slope = rms ? sqrt(linslope) : linslope;
+            detected = slope;
+
+            if(slope > 0.f && (slope > threshold || knee < 1.f)) {
+                if(IS_FAKE_INFINITY(ratio)) {
+                    gain = threshold;
+                } else {
+                    gain = (slope - threshold) / ratio + threshold;
+                }
+                
+                if(knee < 1.f) {
+                    float t = std::min(1.f, std::max(0.f, slope / threshold - knee) / (1.f - knee));
+                    gain = (gain - slope) * t + slope;
+                }
+                
+                gain /= slope;
+            }
+        
+            
+            float outL = ins[0][offset] * gain * makeup;
+            outs[0][offset] = outL;
+
+            float outR = ins[1][offset] * gain * makeup;
+            outs[1][offset] = outR;
+
+            ++offset;
+            
+            float maxLR = std::max(fabs(outL), fabs(outR));
+            
+            if(clip > 0) {
+                --clip;
+            }
+            if(maxLR > 1.f) clip = srate / 10.f; /* blink clip LED for 100 ms */
+            
+            peak -= peak * 0.0001;
+            if(maxLR > peak) {
+                peak = maxLR;
+            }
+        }
+        
+        if(params[param_compression] != NULL) {
+            *params[param_compression] = gain;
+        }
+
+        if(params[param_clip] != NULL) {
+            *params[param_clip] = clip;
+        }
+
+        if(params[param_peak] != NULL) {
+            *params[param_peak] = peak;
+        }
+
+        return inputs_mask;
+    }
+
+    void set_sample_rate(uint32_t sr) {
+            srate = sr;
+            awL.set(sr);
+            awR.set(sr);
+    }
+    inline float output_level(float slope)
+    {
+        float threshold = *params[param_threshold];
+        float ratio = *params[param_ratio];
+        float makeup = *params[param_makeup];
+        float knee = *params[param_knee];
+        
+        if(slope > 0.f && (slope > threshold || knee < 1.f)) {
+            float gain = 0.f;
+            if(IS_FAKE_INFINITY(ratio)) {
+                gain = threshold;
+            } else {
+                gain = (slope - threshold) / ratio + threshold;
+            }
+            
+            if(knee < 1.f) {
+                float t = std::min(1.f, std::max(0.f, slope / threshold - knee) / (1.f - knee));
+                gain = (gain - slope) * t + slope;
+            }
+            return gain * makeup;
+        }
+        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;
+    }
+};
+
 extern std::string get_builtin_modules_rdf();
 
 };
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index b04ae2a..8067bd3 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -21,184 +21,10 @@
 #ifndef __CALF_MODULES_DEV_H
 #define __CALF_MODULES_DEV_H
 
-#include "loudness.h"
-
 namespace calf_plugins {
 
 #if ENABLE_EXPERIMENTAL
 
-class compressor_audio_module: public audio_module<compressor_metadata>, public line_graph_iface {
-private:
-    float linslope, clip, peak, detected;
-    bool aweighting;
-    aweighter awL, awR;
-public:
-
-    float *ins[in_count];
-    float *outs[out_count];
-    float *params[param_count];
-    uint32_t srate;
-    void activate() {
-        linslope = 0.f;
-        peak = 0.f;
-        clip = 0.f;
-    }
-    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;
-        bool average = *params[param_stereo_link] == 0;
-        aweighting = *params[param_aweighting] > 0.5f;
-        float threshold = *params[param_threshold];
-        float ratio = *params[param_ratio];
-        float attack = *params[param_attack];
-        float attack_coeff = std::min(1.f, 1.f / (attack * srate / 4000.f));
-        float release = *params[param_release];
-        float release_coeff = std::min(1.f, 1.f / (release * srate / 4000.f));
-        float makeup = *params[param_makeup];
-        float knee = *params[param_knee];
-
-        numsamples += offset;
-        
-        if(bypass) {
-            int count = numsamples * sizeof(float);
-            memcpy(outs[0], ins[0], count);
-            memcpy(outs[1], ins[1], count);
-
-            if(params[param_compression] != NULL) {
-                *params[param_compression] = 1.f;
-            }
-
-            if(params[param_clip] != NULL) {
-                *params[param_clip] = 0.f;
-            }
-
-            if(params[param_peak] != NULL) {
-                *params[param_peak] = 0.f;
-            }
-      
-            return inputs_mask;
-        }
-
-        float gain = 1.f;
-        
-        while(offset < numsamples) {
-            float left = ins[0][offset];
-            float right = ins[1][offset];
-            if(aweighting) {
-                left = awL.process(left);
-                right = awR.process(right);
-            }
-            float absample = average ? (fabs(left) + fabs(right)) / 2 : std::max(fabs(left), fabs(right));
-            if(rms) absample *= absample;
-            linslope += (absample - linslope) * (absample > linslope ? attack_coeff : release_coeff);
-            float slope = rms ? sqrt(linslope) : linslope;
-            detected = slope;
-
-            if(slope > 0.f && (slope > threshold || knee < 1.f)) {
-                if(IS_FAKE_INFINITY(ratio)) {
-                    gain = threshold;
-                } else {
-                    gain = (slope - threshold) / ratio + threshold;
-                }
-                
-                if(knee < 1.f) {
-                    float t = std::min(1.f, std::max(0.f, slope / threshold - knee) / (1.f - knee));
-                    gain = (gain - slope) * t + slope;
-                }
-                
-                gain /= slope;
-            }
-        
-            
-            float outL = ins[0][offset] * gain * makeup;
-            outs[0][offset] = outL;
-
-            float outR = ins[1][offset] * gain * makeup;
-            outs[1][offset] = outR;
-
-            ++offset;
-            
-            float maxLR = std::max(fabs(outL), fabs(outR));
-            
-            if(clip > 0) {
-                --clip;
-            }
-            if(maxLR > 1.f) clip = srate / 10.f; /* blink clip LED for 100 ms */
-            
-            peak -= peak * 0.0001;
-            if(maxLR > peak) {
-                peak = maxLR;
-            }
-        }
-        
-        if(params[param_compression] != NULL) {
-            *params[param_compression] = gain;
-        }
-
-        if(params[param_clip] != NULL) {
-            *params[param_clip] = clip;
-        }
-
-        if(params[param_peak] != NULL) {
-            *params[param_peak] = peak;
-        }
-
-        return inputs_mask;
-    }
-
-    void set_sample_rate(uint32_t sr) {
-            srate = sr;
-            awL.set(sr);
-            awR.set(sr);
-    }
-    inline float output_level(float slope)
-    {
-        float threshold = *params[param_threshold];
-        float ratio = *params[param_ratio];
-        float makeup = *params[param_makeup];
-        float knee = *params[param_knee];
-        
-        if(slope > 0.f && (slope > threshold || knee < 1.f)) {
-            float gain = 0.f;
-            if(IS_FAKE_INFINITY(ratio)) {
-                gain = threshold;
-            } else {
-                gain = (slope - threshold) / ratio + threshold;
-            }
-            
-            if(knee < 1.f) {
-                float t = std::min(1.f, std::max(0.f, slope / threshold - knee) / (1.f - knee));
-                gain = (gain - slope) * t + slope;
-            }
-            return gain * makeup;
-        }
-        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;
-    }
-};
-
 #endif
     
 };
diff --git a/src/modules.cpp b/src/modules.cpp
index a0e89be..40c3ea3 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -171,8 +171,6 @@ CALF_PLUGIN_INFO(multichorus) = { 0x8501, "MultiChorus", "Calf MultiChorus", "Kr
 
 ////////////////////////////////////////////////////////////////////////////
 
-#if ENABLE_EXPERIMENTAL
-
 CALF_PORT_NAMES(compressor) = {"In L", "In R", "Out L", "Out R"};
 
 const char *compressor_detection_names[] = { "RMS", "Peak" };
@@ -196,8 +194,6 @@ CALF_PORT_PROPS(compressor) = {
 
 CALF_PLUGIN_INFO(compressor) = { 0x8502, "Compressor", "Calf Compressor", "Thor Harald Johansen", calf_plugins::calf_copyright_info, "CompressorPlugin" };
 
-#endif
-
 ////////////////////////////////////////////////////////////////////////////
 
 CALF_PORT_NAMES(monosynth) = {

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list