[SCM] calf/master: min release and release coeff for multiband limiter

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


The following commit has been merged in the master branch:
commit 554950f5fd6bcdb8f5da2f5a00479f37691e5f8d
Author: Markus Schmidt <schmidt at boomshop.net>
Date:   Thu Dec 1 14:36:34 2011 +0100

    min release and release coeff for multiband limiter

diff --git a/gui/gui-multibandlimiter.xml b/gui/gui-multibandlimiter.xml
index 1ded65c..389c90a 100644
--- a/gui/gui-multibandlimiter.xml
+++ b/gui/gui-multibandlimiter.xml
@@ -119,62 +119,92 @@
                 </if>
             </vbox>
         </frame>
-        <frame label="Bands">
-            <vbox>
-                <hbox>
-                    <vbox>
-                        <label param="weight0" />
-                        <knob param="weight0" size="2" />
-                        <value param="weight0" />
-                    </vbox>
-                    <vumeter attach-x="1" attach-y="0" param="att0" mode="2" hold="1.5" falloff="2.5" expand-x="1" fill-y="0" expand-y="0" height="12" position="2" />
-                    <vbox>
-                        <label param="release0" />
-                        <knob param="release0" size="2" />
-                        <value param="release0" />
-                    </vbox>
-                <hbox>
+        <vbox>
+            <frame label="Low Band">
+            
                 <hbox>
-                    <vbox>
-                        <label param="weight1" />
-                        <knob param="weight1" size="2" />
-                        <value param="weight1" />
-                    </vbox>
-                    <vumeter attach-x="1" attach-y="0" param="att1" mode="2" hold="1.5" falloff="2.5" expand-x="1" fill-y="0" expand-y="0" height="12" position="2" />
-                    <vbox>
-                        <label param="release1" />
-                        <knob param="release1" size="2" />
-                        <value param="release1" />
-                    </vbox>
-                <hbox>
-                <hbox>
-                    <vbox>
-                        <label param="weight2" />
-                        <knob param="weight2" size="2" />
-                        <value param="weight2" />
-                    </vbox>
-                    <vumeter attach-x="1" attach-y="0" param="att2" mode="2" hold="1.5" falloff="2.5" expand-x="1" fill-y="0" expand-y="0" height="12" position="2" />
-                    <vbox>
-                        <label param="release2" />
-                        <knob param="release2" size="2" />
-                        <value param="release2" />
-                    </vbox>
+                    <hbox>
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="weight0" align-x="1.0" />
+                            <value param="weight0" align-x="1.0" />
+                        </vbox>
+                        <knob param="weight0" size="2" type="1" />
+                    </hbox>
+                    <vumeter param="att0" mode="2" hold="1.5" falloff="2.5" width="100" height="28" position="1" />
+                    <hbox>
+                        <knob param="release0" size="2" type="1" />
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="release0" align-x="0.0" />
+                            <value param="release0" align-x="0.0" />
+                        </vbox>
+                    </hbox>
+                </hbox>
+            </frame>
+            <frame label="LowMid Band">
                 <hbox>
+                    <hbox>
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="weight1" align-x="1.0" />
+                            <value param="weight1" align-x="1.0" />
+                        </vbox>
+                        <knob param="weight1" size="2" type="1" />
+                    </hbox>
+                    <vumeter param="att1" mode="2" hold="1.5" falloff="2.5" width="100" height="28" position="1" />
+                    <hbox>
+                        <knob param="release1" size="2" type="1" />
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="release1" align-x="0.0" />
+                            <value param="release1" align-x="0.0" />
+                        </vbox>
+                    </hbox>
+                </hbox>
+            </frame>
+            <frame label="HiMid Band">
                 <hbox>
-                    <vbox>
-                        <label param="weight3" />
-                        <knob param="weight3" size="2" />
-                        <value param="weight3" />
-                    </vbox>
-                    <vumeter attach-x="1" attach-y="0" param="att3" mode="2" hold="1.5" falloff="2.5" expand-x="1" fill-y="0" expand-y="0" height="12" position="2" />
-                    <vbox>
-                        <label param="release3" />
-                        <knob param="release3" size="2" />
-                        <value param="release3" />
-                    </vbox>
+                    <hbox>
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="weight2" align-x="1.0" />
+                            <value param="weight2" align-x="1.0" />
+                        </vbox>
+                        <knob param="weight2" size="2" type="1" />
+                    </hbox>
+                    <vumeter param="att2" mode="2" hold="1.5" falloff="2.5" width="100" height="28" position="1" />
+                    <hbox>
+                        <knob param="release2" size="2" type="1" />
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="release2" align-x="0.0" />
+                            <value param="release2" align-x="0.0" />
+                        </vbox>
+                    </hbox>
+                </hbox>
+            </frame>
+            <frame label="High Band">
                 <hbox>
-            </vbox>
-        </frame>
-        
+                    <hbox>
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="weight3" align-x="1.0" />
+                            <value param="weight3" align-x="1.0" />
+                        </vbox>
+                        <knob param="weight3" size="2" type="1" />
+                    </hbox>
+                    <vumeter param="att3" mode="2" hold="1.5" falloff="2.5" width="100" height="28" position="1" />
+                    <hbox>
+                        <knob param="release3" size="2" type="1" />
+                        <vbox expand="0" fill="0" spacing="3">
+                            <label/>
+                            <label param="release3" align-x="0.0" />
+                            <value param="release3" align-x="0.0" />
+                        </vbox>
+                    </hbox>
+                </hbox>
+            </frame>
+        </vbox>
     </hbox>
 </table>    
diff --git a/src/audio_fx.cpp b/src/audio_fx.cpp
index 649f99b..7fcdf8e 100644
--- a/src/audio_fx.cpp
+++ b/src/audio_fx.cpp
@@ -606,6 +606,7 @@ void lookahead_limiter::process(float &left, float &right, float * multi_buffer)
     
     // are we using multiband? get the multiband coefficient
     float multi_coeff = (use_multi) ? multi_buffer[pos] : 1.f;
+    //if(debug) printf("%03d: %.5f\n", pos, multi_coeff);
     
     // input peak - impact in left or right channel?
     peak = fabs(left) > fabs(right) ? fabs(left) : fabs(right);
diff --git a/src/calf/audio_fx.h b/src/calf/audio_fx.h
index c0df094..7f56472 100644
--- a/src/calf/audio_fx.h
+++ b/src/calf/audio_fx.h
@@ -591,7 +591,7 @@ private:
 public:
     lookahead_limiter();
     void set_multi(bool set);
-    void process(float &left, float &right, float * multi_buffer);
+    void process(float &left, float &right, float *multi_buffer);
     void set_sample_rate(uint32_t sr);
     void set_params(float l, float a, float r, float weight = 1.f, bool ar = false, bool d = false);
     float get_attenuation();
diff --git a/src/calf/modules_comp.h b/src/calf/modules_comp.h
index 06763b0..538e18b 100644
--- a/src/calf/modules_comp.h
+++ b/src/calf/modules_comp.h
@@ -170,7 +170,7 @@ private:
     uint32_t clip_inL, clip_inR, clip_outL, clip_outR;
     float meter_inL, meter_inR, meter_outL, meter_outR;
     gain_reduction_audio_module strip[strips];
-    dsp::biquad_d2<float> lpL[3][3], lpR[3][3], hpL[3][3], hpR[3][3];
+    dsp::biquad_d2<float> lpL[strips - 1][3], lpR[strips - 1][3], hpL[strips - 1][3], hpR[strips - 1][3];
     float freq_old[strips - 1], sep_old[strips - 1], q_old[strips - 1];
     int mode, mode_old;
 public:
diff --git a/src/calf/modules_limit.h b/src/calf/modules_limit.h
index 1626ab3..2f8cae2 100644
--- a/src/calf/modules_limit.h
+++ b/src/calf/modules_limit.h
@@ -60,13 +60,14 @@ private:
     int mode, mode_old;
     float meter_inL, meter_inR, meter_outL, meter_outR;
     dsp::lookahead_limiter strip[strips];
-    dsp::biquad_d2<float> lpL[3][3], lpR[3][3], hpL[3][3], hpR[3][3];
+    dsp::biquad_d2<float> lpL[strips - 1][3], lpR[strips - 1][3], hpL[strips - 1][3], hpR[strips - 1][3];
     float freq_old[strips - 1], sep_old[strips - 1], q_old[strips - 1];
     unsigned int pos;
     unsigned int buffer_size;
     float attack_old;
     float *buffer;
     int channels;
+    float striprel[strips];
 public:
     uint32_t srate;
     bool is_active;
diff --git a/src/metadata.cpp b/src/metadata.cpp
index fdbd299..717271c 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -537,9 +537,9 @@ CALF_PORT_PROPS(multibandlimiter) = {
     { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outL", "0dB-OutL" },
     { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outR", "0dB-OutR" },
     
-    { 120,         10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq0", "Split 1/2" },
-    { 1000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq1", "Split 2/3" },
-    { 6000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq2", "Split 3/4" },
+    { 100,         10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq0", "Split 1/2" },
+    { 750,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq1", "Split 2/3" },
+    { 5000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq2", "Split 3/4" },
     
     { -0.17,      -0.5,         0.5,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep0", "S1" },
     { -0.17,      -0.5,         0.5,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep1", "S2" },
@@ -553,7 +553,7 @@ CALF_PORT_PROPS(multibandlimiter) = {
     
     { 1,      0.0625, 1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "limit", "Limit" },
     { 5,         0.1,        100,  0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "attack", "Attack" },
-    { 50,         1,        1000,  0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "release", "Release" },
+    { 40,         1,        1000,  0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "release", "Release" },
     { 1,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "minrel", "Min Release" },
     
     { 1,           0.125,     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, "att0", "Low" },
@@ -561,15 +561,15 @@ CALF_PORT_PROPS(multibandlimiter) = {
     { 1,           0.125,     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, "att2", "HMid" },
     { 1,           0.125,     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, "att3", "Hi" },
     
-    { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "weight0", "Weight 1" },
-    { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "weight1", "Weight 2" },
-    { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "weight2", "Weight 3" },
+    { 0.2f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "weight0", "Weight 1" },
+    { -0.2f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "weight1", "Weight 2" },
+    { 0.1f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "weight2", "Weight 3" },
     { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "weight3", "Weight 4" },
     
-    { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "release0", "Release 1" },
+    { 0.2f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "release0", "Release 1" },
     { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "release1", "Release 2" },
-    { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "release2", "Release 3" },
-    { 0.f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "release3", "Release 4" },
+    { -0.1f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "release2", "Release 3" },
+    { -0.2f,      -1.f,         1.f,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "release3", "Release 4" },
     
     {}
 };
diff --git a/src/modules_limit.cpp b/src/modules_limit.cpp
index daf031f..43d2ab7 100644
--- a/src/modules_limit.cpp
+++ b/src/modules_limit.cpp
@@ -297,23 +297,23 @@ void multibandlimiter_audio_module::params_changed()
     }
     // set the params of all strips
     float rel;
-    rel = *params[param_release] * *params[param_release0]
-    rel = (*params[param_minrel] < 0.5) ? std::max(3 * (1.f / 30), rel);
-    strip[0].set_params(*params[param_limit], *params[param_attack], rel, pow(0.5, *params[param_weight0] * -1), true, true);
-    rel = *params[param_release] * *params[param_release0]
-    rel = (*params[param_minrel] < 0.5) ? std::max(3 * (1.f / *params[param_freq0]), rel);
-    strip[1].set_params(*params[param_limit], *params[param_attack], rel, pow(0.5, *params[param_weight1] * -1), true);
-    rel = *params[param_release] * *params[param_release0]
-    rel = (*params[param_minrel] < 0.5) ? std::max(3 * (1.f / *params[param_freq1]), rel);
-    strip[2].set_params(*params[param_limit], *params[param_attack], rel, pow(0.5, *params[param_weight2] * -1), true);
-    rel = *params[param_release] * *params[param_release0]
-    rel = (*params[param_minrel] < 0.5) ? std::max(3 * (1.f / *params[param_freq2]), rel);
-    strip[3].set_params(*params[param_limit], *params[param_attack], rel, pow(0.5, *params[param_weight3] * -1), true);
+    rel = *params[param_release] *  pow(0.25, *params[param_release0] * -1);
+    rel = (*params[param_minrel] > 0.5) ? std::max(3 * (1.f / 30), rel) : rel;
+    strip[0].set_params(*params[param_limit], *params[param_attack], rel, pow(0.25, *params[param_weight0] * -1), true, true);
+    rel = *params[param_release] *  pow(0.25, *params[param_release0] * -1);
+    rel = (*params[param_minrel] > 0.5) ? std::max(3 * (1.f / *params[param_freq0]), rel) : rel;
+    strip[1].set_params(*params[param_limit], *params[param_attack], rel, pow(0.25, *params[param_weight1] * -1), true);
+    rel = *params[param_release] *  pow(0.25, *params[param_release0] * -1);
+    rel = (*params[param_minrel] > 0.5) ? std::max(3 * (1.f / *params[param_freq1]), rel) : rel;
+    strip[2].set_params(*params[param_limit], *params[param_attack], rel, pow(0.25, *params[param_weight2] * -1), true);
+    rel = *params[param_release] *  pow(0.25, *params[param_release0] * -1);
+    rel = (*params[param_minrel] > 0.5) ? std::max(3 * (1.f / *params[param_freq2]), rel) : rel;
+    strip[3].set_params(*params[param_limit], *params[param_attack], rel, pow(0.25, *params[param_weight3] * -1), true);
     
     // rebuild multiband buffer
     if( *params[param_attack] != attack_old) {
         // rebuild buffer
-        buffer_size = (int)srate * *params[param_attack] * channels; // buffer size attack rate
+        buffer_size = (int)(srate * (*params[param_attack] / 1000.f) * channels); // buffer size attack rate
         buffer = (float*) calloc(buffer_size, sizeof(float));
         memset(buffer, 0, buffer_size * sizeof(float)); // reset buffer to zero
         attack_old = *params[param_attack];
@@ -381,6 +381,18 @@ uint32_t multibandlimiter_audio_module::process(uint32_t offset, uint32_t numsam
             // in level
             inR *= *params[param_level_in];
             inL *= *params[param_level_in];
+            // even out filters gain reduction
+            // 3dB - levelled manually (based on default sep and q settings)
+            switch(mode) {
+                case 0:
+                    inL *= 1.414213562;
+                    inR *= 1.414213562;
+                    break;
+                case 1:
+                    inL *= 0.88;
+                    inR *= 0.88;
+                    break;
+            }
             // out vars
             float outL = 0.f;
             float outR = 0.f;
@@ -440,7 +452,7 @@ uint32_t multibandlimiter_audio_module::process(uint32_t offset, uint32_t numsam
             
             // write multiband coefficient to buffer
             buffer[pos] = *params[param_limit] / std::min(fabs(sum_left), fabs(sum_right));
-            
+            //printf("%03d: %.5f\n", pos, fabs(sum_left));
             for (int i = 0; i < strips; i++) {
                 // process gain reduction
                 strip[i].process(_tmpL[i], _tmpR[i], buffer);
@@ -452,18 +464,6 @@ uint32_t multibandlimiter_audio_module::process(uint32_t offset, uint32_t numsam
                 outR += _tmpR[i];
             } // process single strip again for limiter
             
-            // even out filters gain reduction
-            // 3dB - levelled manually (based on default sep and q settings)
-            switch(mode) {
-                case 0:
-                    outL *= 1.414213562;
-                    outR *= 1.414213562;
-                    break;
-                case 1:
-                    outL *= 0.88;
-                    outR *= 0.88;
-                    break;
-            }
             // out level
             outL *= *params[param_level_out];
             outR *= *params[param_level_out];
@@ -500,6 +500,7 @@ uint32_t multibandlimiter_audio_module::process(uint32_t offset, uint32_t numsam
             }
             // next sample
             ++offset;
+            pos = (pos + channels) % buffer_size;
         } // cycle trough samples
         
     } // process all strips (no bypass)
@@ -526,7 +527,6 @@ uint32_t multibandlimiter_audio_module::process(uint32_t offset, uint32_t numsam
         ACTIVE_COMPRESSION(3)
     }
     
-    pos = (pos += channels) % buffer_size;
     // whatever has to be returned x)
     return outputs_mask;
 }

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list