[SCM] calf/master: Bass enhancer added

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


The following commit has been merged in the master branch:
commit c8e7f24facbd9a61857775777072596f2431c42b
Author: Markus Schmidt <schmidt at boomshop.net>
Date:   Fri Nov 13 06:27:27 2009 +0100

    Bass enhancer added

diff --git a/gui/gui-enhancer.xml b/gui/gui-bassenhancer.xml
similarity index 98%
copy from gui/gui-enhancer.xml
copy to gui/gui-bassenhancer.xml
index 20695ae..302a1e1 100644
--- a/gui/gui-enhancer.xml
+++ b/gui/gui-bassenhancer.xml
@@ -28,7 +28,7 @@
         <label param="listen" attach-x="6" attach-y="0" expand-x="0" fill-x="0" />
         <toggle param="listen" attach-x="6" attach-y="1" attach-h="2" expand-x="0" fill-x="0" />
     </table>
-    <frame label="Enhancer">
+    <frame label="Bass Enhancer">
         <hbox spacing="25">
             <vbox>
                 <label param="drive" />
diff --git a/gui/gui-enhancer.xml b/gui/gui-exciter.xml
similarity index 98%
rename from gui/gui-enhancer.xml
rename to gui/gui-exciter.xml
index 20695ae..673603b 100644
--- a/gui/gui-enhancer.xml
+++ b/gui/gui-exciter.xml
@@ -28,7 +28,7 @@
         <label param="listen" attach-x="6" attach-y="0" expand-x="0" fill-x="0" />
         <toggle param="listen" attach-x="6" attach-y="1" attach-h="2" expand-x="0" fill-x="0" />
     </table>
-    <frame label="Enhancer">
+    <frame label="Exciter">
         <hbox spacing="25">
             <vbox>
                 <label param="drive" />
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 6eb4887..26f1a4c 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -244,14 +244,23 @@ struct saturator_metadata: public plugin_metadata<saturator_metadata>
            param_p_freq, param_p_level, param_p_q, param_count };
     PLUGIN_NAME_ID_LABEL("saturator", "saturator", "Saturator")
 };
-/// Markus's Enhancer - metadata
-struct enhancer_metadata: public plugin_metadata<enhancer_metadata>
+/// Markus's Exciter - metadata
+struct exciter_metadata: public plugin_metadata<exciter_metadata>
 {
     enum { in_count = 2, out_count = 2, ins_optional = 1, outs_optional = 1, support_midi = false, require_midi = false, rt_capable = true };
     enum { param_bypass, param_level_in, param_level_out, param_amount, param_meter_in,
            param_meter_out, param_clip_in, param_clip_out, param_drive, param_blend, param_meter_drive,
            param_freq, param_listen, param_count };
-    PLUGIN_NAME_ID_LABEL("enhancer", "enhancer", "Enhancer")
+    PLUGIN_NAME_ID_LABEL("exciter", "exciter", "Exciter")
+};
+/// Markus's Bass Enhancer - metadata
+struct bassenhancer_metadata: public plugin_metadata<bassenhancer_metadata>
+{
+    enum { in_count = 2, out_count = 2, ins_optional = 1, outs_optional = 1, support_midi = false, require_midi = false, rt_capable = true };
+    enum { param_bypass, param_level_in, param_level_out, param_amount, param_meter_in,
+           param_meter_out, param_clip_in, param_clip_out, param_drive, param_blend, param_meter_drive,
+           param_freq, param_listen, param_count };
+    PLUGIN_NAME_ID_LABEL("bassenhancer", "bassenhancer", "Bass Enhancer")
 };
 /// Organ - enums for parameter IDs etc. (this mess is caused by organ split between plugin and generic class - which was
 /// a bad design decision and should be sorted out some day) XXXKF @todo
diff --git a/src/calf/modulelist.h b/src/calf/modulelist.h
index c9d36d1..57f47e4 100644
--- a/src/calf/modulelist.h
+++ b/src/calf/modulelist.h
@@ -17,7 +17,8 @@
     PER_MODULE_ITEM(equalizer8band, false, "equalizer8band")
     PER_MODULE_ITEM(equalizer12band, false, "equalizer12band")
     PER_MODULE_ITEM(saturator, false, "saturator")
-    PER_MODULE_ITEM(enhancer, false, "enhancer")
+    PER_MODULE_ITEM(exciter, false, "exciter")
+    PER_MODULE_ITEM(bassenhancer, false, "bassenhancer")
 #ifdef ENABLE_EXPERIMENTAL
     PER_MODULE_ITEM(fluidsynth, true, "fluidsynth")
     PER_MODULE_ITEM(wavetable, true, "wavetable")
diff --git a/src/calf/modules.h b/src/calf/modules.h
index e64b937..000505f 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -1321,8 +1321,8 @@ public:
     uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
 };
 
-/// Enhancer by Markus Schmidt (based on Krzysztof's filters and distortion algorythm)
-class enhancer_audio_module: public audio_module<enhancer_metadata> {
+/// Exciter by Markus Schmidt (based on Krzysztof's filters and distortion algorythm)
+class exciter_audio_module: public audio_module<exciter_metadata> {
 private:
     float freq_old;
     uint32_t clip_in, clip_out;
@@ -1335,7 +1335,29 @@ public:
     float *params[param_count];
     uint32_t srate;
     bool is_active;
-    enhancer_audio_module();
+    exciter_audio_module();
+    void activate();
+    void deactivate();
+    void params_changed();
+    void set_sample_rate(uint32_t sr);
+    uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
+};
+
+/// Bass Enhancer by Markus Schmidt (based on Krzysztof's filters and distortion algorythm)
+class bassenhancer_audio_module: public audio_module<bassenhancer_metadata> {
+private:
+    float freq_old;
+    uint32_t clip_in, clip_out;
+    float meter_in, meter_out, meter_drive;
+    biquad_d2<float> lp[2][4];
+    distortion_audio_module dist[2];
+public:
+    float *ins[in_count];
+    float *outs[out_count];
+    float *params[param_count];
+    uint32_t srate;
+    bool is_active;
+    bassenhancer_audio_module();
     void activate();
     void deactivate();
     void params_changed();
diff --git a/src/modules.cpp b/src/modules.cpp
index c33a617..e3b747f 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -594,9 +594,9 @@ CALF_PLUGIN_INFO(saturator) = { 0x8502, "Saturator", "Calf Saturator", "Markus S
 
 ////////////////////////////////////////////////////////////////////////////
 
-CALF_PORT_NAMES(enhancer) = {"In L", "In R", "Out L", "Out R"};
+CALF_PORT_NAMES(exciter) = {"In L", "In R", "Out L", "Out R"};
 
-CALF_PORT_PROPS(enhancer) = {
+CALF_PORT_PROPS(exciter) = {
     { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
     { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input" },
     { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output" },
@@ -614,11 +614,32 @@ CALF_PORT_PROPS(enhancer) = {
     { 0,          0,            1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "listen", "Listen" },
 };
 
-CALF_PLUGIN_INFO(enhancer) = { 0x8502, "Enhancer", "Calf Enhancer", "Markus Schmidt / Krzysztof Foltman", calf_plugins::calf_copyright_info, "DistortionPlugin" };
-
+CALF_PLUGIN_INFO(exciter) = { 0x8502, "Exciter", "Calf Exciter", "Markus Schmidt / Krzysztof Foltman", calf_plugins::calf_copyright_info, "DistortionPlugin" };
 
 ////////////////////////////////////////////////////////////////////////////
 
+CALF_PORT_NAMES(bassenhancer) = {"In L", "In R", "Out L", "Out R"};
+
+CALF_PORT_PROPS(bassenhancer) = {
+    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
+    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input" },
+    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output" },
+    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_NOBOUNDS, NULL, "amount", "Amount" },
+    { 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, "meter_in", "Input" },
+    { 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, "meter_out", "Output" },
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_in", "0dB" },
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_out", "0dB" },
+    
+    { 8.5,         0.1,         10,    0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "drive", "Harmonics" },
+    { 0,          -10,          10,    0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_FADER | PF_UNIT_COEF, NULL, "blend", "Blend harmonics" },
+    { 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, "meter_drive", "Harmonics level" },
+    
+    { 120,        10,           250,   0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "freq", "Scope" },
+    { 0,          0,            1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "listen", "Listen" },
+};
+
+CALF_PLUGIN_INFO(bassenhancer) = { 0x8502, "BassEnhancer", "Calf Bass Enhancer", "Markus Schmidt / Krzysztof Foltman", calf_plugins::calf_copyright_info, "DistortionPlugin" };
+
 ////////////////////////////////////////////////////////////////////////////
 
 CALF_PORT_NAMES(monosynth) = {
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index 2c71e75..970ddda 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -3150,13 +3150,13 @@ uint32_t saturator_audio_module::process(uint32_t offset, uint32_t numsamples, u
     return outputs_mask;
 }
 
-/// Enhancer Band by Markus Schmidt
+/// Exciter by Markus Schmidt
 ///
 /// This module is based on Krzysztof's filters and distortion routine.
-/// It provides a blendable saturation stage followed by a highpass, a lowpass and a peak filter
+/// It sends the signal through a highpass, saturates it and sends it through a highpass again
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
-enhancer_audio_module::enhancer_audio_module()
+exciter_audio_module::exciter_audio_module()
 {
     is_active = false;
     srate = 0;
@@ -3167,18 +3167,18 @@ enhancer_audio_module::enhancer_audio_module()
     meter_drive = 0.f;
 }
 
-void enhancer_audio_module::activate()
+void exciter_audio_module::activate()
 {
     is_active = true;
     // set all filters
     params_changed();
 }
-void enhancer_audio_module::deactivate()
+void exciter_audio_module::deactivate()
 {
     is_active = false;
 }
 
-void enhancer_audio_module::params_changed()
+void exciter_audio_module::params_changed()
 {
     // set the params of all filters
     if(*params[param_freq] != freq_old) {
@@ -3200,7 +3200,7 @@ void enhancer_audio_module::params_changed()
         dist[1].set_params(*params[param_blend], *params[param_drive]);
 }
 
-void enhancer_audio_module::set_sample_rate(uint32_t sr)
+void exciter_audio_module::set_sample_rate(uint32_t sr)
 {
     srate = sr;
     dist[0].set_sample_rate(sr);
@@ -3208,7 +3208,7 @@ void enhancer_audio_module::set_sample_rate(uint32_t sr)
         dist[1].set_sample_rate(sr);
 }
 
-uint32_t enhancer_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+uint32_t exciter_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
 {
     bool bypass = *params[param_bypass] > 0.5f;
     numsamples += offset;
@@ -3373,6 +3373,230 @@ uint32_t enhancer_audio_module::process(uint32_t offset, uint32_t numsamples, ui
     return outputs_mask;
 }
 
+/// Bass Enhancer by Markus Schmidt
+///
+/// This module is based on Krzysztof's filters and distortion routine.
+/// It sends the signal through a lowpass, saturates it and sends it through a lowpass again
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+bassenhancer_audio_module::bassenhancer_audio_module()
+{
+    is_active = false;
+    srate = 0;
+    clip_in    = 0.f;
+    clip_out   = 0.f;
+    meter_in  = 0.f;
+    meter_out = 0.f;
+    meter_drive = 0.f;
+}
+
+void bassenhancer_audio_module::activate()
+{
+    is_active = true;
+    // set all filters
+    params_changed();
+}
+void bassenhancer_audio_module::deactivate()
+{
+    is_active = false;
+}
+
+void bassenhancer_audio_module::params_changed()
+{
+    // set the params of all filters
+    if(*params[param_freq] != freq_old) {
+        lp[0][0].set_lp_rbj(*params[param_freq], 0.707, (float)srate);
+        lp[0][1].copy_coeffs(lp[0][0]);
+        lp[0][2].copy_coeffs(lp[0][0]);
+        lp[0][3].copy_coeffs(lp[0][0]);
+        if(in_count > 1 && out_count > 1) {
+            lp[1][0].copy_coeffs(lp[0][0]);
+            lp[1][1].copy_coeffs(lp[0][0]);
+            lp[1][2].copy_coeffs(lp[0][0]);
+            lp[1][3].copy_coeffs(lp[0][0]);
+        }
+        freq_old = *params[param_freq];
+    }
+    // set distortion
+    dist[0].set_params(*params[param_blend], *params[param_drive]);
+    if(in_count > 1 && out_count > 1)
+        dist[1].set_params(*params[param_blend], *params[param_drive]);
+}
+
+void bassenhancer_audio_module::set_sample_rate(uint32_t sr)
+{
+    srate = sr;
+    dist[0].set_sample_rate(sr);
+    if(in_count > 1 && out_count > 1)
+        dist[1].set_sample_rate(sr);
+}
+
+uint32_t bassenhancer_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+{
+    bool bypass = *params[param_bypass] > 0.5f;
+    numsamples += offset;
+    if(bypass) {
+        // everything bypassed
+        while(offset < numsamples) {
+            if(in_count > 1 && out_count > 1) {
+                outs[0][offset] = ins[0][offset];
+                outs[1][offset] = ins[1][offset];
+            } else if(in_count > 1) {
+                outs[0][offset] = (ins[0][offset] + ins[1][offset]) / 2;
+            } else if(out_count > 1) {
+                outs[0][offset] = ins[0][offset];
+                outs[1][offset] = ins[0][offset];
+            } else {
+                outs[0][offset] = ins[0][offset];
+            }
+            ++offset;
+        }
+        // displays, too
+        clip_in    = 0.f;
+        clip_out   = 0.f;
+        meter_in  = 0.f;
+        meter_out = 0.f;
+        meter_drive = 0.f;
+    } else {
+        
+        clip_in    -= std::min(clip_in,  numsamples);
+        clip_out   -= std::min(clip_out, numsamples);
+        meter_in = 0.f;
+        meter_out = 0.f;
+        meter_drive = 0.f;
+        
+        // process
+        while(offset < numsamples) {
+            // cycle through samples
+            float out[2], in[2] = {0.f, 0.f};
+            float maxIn, maxOut, maxDrive = 0.f;
+            int c = 0;
+            
+            if(in_count > 1 && out_count > 1) {
+                // stereo in/stereo out
+                // handle full stereo
+                in[0] = ins[0][offset];
+                in[0] *= *params[param_level_in];
+                in[1] = ins[1][offset];
+                in[1] *= *params[param_level_in];
+                c = 2;
+            } else {
+                // in and/or out mono
+                // handle mono
+                in[0] = ins[0][offset];
+                in[0] *= *params[param_level_in];
+                in[1] = in[0];
+                c = 1;
+            }
+            
+            float proc[2];
+            proc[0] = in[0];
+            proc[1] = in[1];
+            
+            for (int i = 0; i < c; ++i) {
+                // all pre filters in chain
+                proc[i] = lp[i][1].process(lp[i][0].process(proc[i]));
+                
+                // saturate
+                proc[i] = dist[i].process(proc[i]);
+
+                // all post filters in chain
+                proc[i] = lp[i][2].process(lp[i][3].process(proc[i]));
+            }
+            
+            if(in_count > 1 && out_count > 1) {
+                // full stereo
+                if(*params[param_listen] > 0.f)
+                    out[0] = proc[0] * *params[param_amount] * *params[param_level_out];
+                else
+                    out[0] = (proc[0] * *params[param_amount] + in[0]) * *params[param_level_out];
+                outs[0][offset] = out[0];
+                if(*params[param_listen] > 0.f)
+                    out[1] = proc[1] * *params[param_amount] * *params[param_level_out];
+                else
+                    out[1] = (proc[1] * *params[param_amount] + in[1]) * *params[param_level_out];
+                outs[1][offset] = out[1];
+                maxIn = std::max(fabs(in[0]), fabs(in[1]));
+                maxOut = std::max(fabs(out[0]), fabs(out[1]));
+                maxDrive = std::max(dist[0].get_distortion_level() * *params[param_amount],
+                                            dist[1].get_distortion_level() * *params[param_amount]);
+            } else if(out_count > 1) {
+                // mono -> pseudo stereo
+                if(*params[param_listen] > 0.f)
+                    out[0] = proc[0] * *params[param_amount] * *params[param_level_out];
+                else
+                    out[0] = (proc[0] * *params[param_amount] + in[0]) * *params[param_level_out];
+                outs[0][offset] = out[0];
+                out[1] = out[0];
+                outs[1][offset] = out[1];
+                maxOut = fabs(out[0]);
+                maxIn = fabs(in[0]);
+                maxDrive = dist[0].get_distortion_level() * *params[param_amount];
+            } else {
+                // stereo -> mono
+                // or full mono
+                if(*params[param_listen] > 0.f)
+                    out[0] = proc[0] * *params[param_amount] * *params[param_level_out];
+                else
+                    out[0] = (proc[0] * *params[param_amount] + in[0]) * *params[param_level_out];
+                outs[0][offset] = out[0];
+                maxIn = fabs(in[0]);
+                maxOut = fabs(out[0]);
+                maxDrive = dist[0].get_distortion_level() * *params[param_amount];
+            }
+            
+            if(maxIn > 1.f) {
+                clip_in  = srate >> 3;
+            }
+            if(maxOut > 1.f) {
+                clip_out = srate >> 3;
+            }
+            // set up in / out meters
+            if(maxIn > meter_in) {
+                meter_in = maxIn;
+            }
+            if(maxOut > meter_out) {
+                meter_out = maxOut;
+            }
+            if(maxDrive > meter_drive) {
+                meter_drive = maxDrive;
+            }
+            
+            // next sample
+            ++offset;
+        } // cycle trough samples
+        // clean up
+        lp[0][0].sanitize();
+        lp[1][0].sanitize();
+        lp[0][1].sanitize();
+        lp[1][1].sanitize();
+        lp[0][2].sanitize();
+        lp[1][2].sanitize();
+        lp[0][3].sanitize();
+        lp[1][3].sanitize();
+    }
+    // draw meters
+    if(params[param_clip_in] != NULL) {
+        *params[param_clip_in] = clip_in;
+    }
+    if(params[param_clip_out] != NULL) {
+        *params[param_clip_out] = clip_out;
+    }
+    
+    if(params[param_meter_in] != NULL) {
+        *params[param_meter_in] = meter_in;
+    }
+    if(params[param_meter_out] != NULL) {
+        *params[param_meter_out] = meter_out;
+    }
+    if(params[param_meter_drive] != NULL) {
+        *params[param_meter_drive] = meter_drive;
+    }
+    // whatever has to be returned x)
+    return outputs_mask;
+}
+
+
 /// Distortion Module by Krzysztof Foltman
 ///
 /// This module provides a blendable saturation stage

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list