[SCM] calf/master: + Organ: add global two-band EQ

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


The following commit has been merged in the master branch:
commit 1015d3f07fff3ad13c3c11529ecfbb4ff0ce6ad4
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Apr 12 19:41:25 2009 +0100

    + Organ: add global two-band EQ

diff --git a/gui/gui-organ.xml b/gui/gui-organ.xml
index f5b08ba..2240746 100644
--- a/gui/gui-organ.xml
+++ b/gui/gui-organ.xml
@@ -410,6 +410,30 @@
             </hbox>
           </vbox>
         </frame>
+        <frame label="Global EQ">
+          <hbox>
+            <vbox>
+              <label param="bass_freq"/>
+              <knob param="bass_freq"/>
+              <value param="bass_freq"/>
+            </vbox>
+            <vbox>
+              <label param="bass_gain"/>
+              <knob param="bass_gain"/>
+              <value param="bass_gain"/>
+            </vbox>
+            <vbox>
+              <label param="treble_freq"/>
+              <knob param="treble_freq"/>
+              <value param="treble_freq"/>
+            </vbox>
+            <vbox>
+              <label param="treble_gain"/>
+              <knob param="treble_gain"/>
+              <value param="treble_gain"/>
+            </vbox>
+          </hbox>
+        </frame>
       </vbox>
     </hbox>
     <vbox page="Advanced">
diff --git a/src/calf/audio_fx.h b/src/calf/audio_fx.h
index f90ed76..b8260f1 100644
--- a/src/calf/audio_fx.h
+++ b/src/calf/audio_fx.h
@@ -24,6 +24,7 @@
 #include <complex>
 #include <iostream>
 #include <calf/biquad.h>
+#include <calf/onepole.h>
 #include "primitives.h"
 #include "delay.h"
 #include "fixed_point.h"
@@ -738,6 +739,49 @@ public:
     }
 };
 
+class two_band_eq
+{
+private:
+    dsp::onepole<float> lowcut, highcut;
+    float low_gain, high_gain;
+
+public:
+    void reset()
+    {
+        lowcut.reset();
+        highcut.reset();
+    }
+    
+    inline float process(float v)
+    {
+        v = dsp::lerp(lowcut.process_hp(v), v, low_gain);
+        v = dsp::lerp(highcut.process_lp(v), v, high_gain);
+        return v;
+    }
+    
+    inline void copy_coeffs(const two_band_eq &src)
+    {
+        lowcut.copy_coeffs(src.lowcut);
+        highcut.copy_coeffs(src.highcut);
+        low_gain = src.low_gain;
+        high_gain = src.high_gain;
+    }
+    
+    void sanitize()
+    {
+        lowcut.sanitize();
+        highcut.sanitize();
+    }
+    
+    void set(float _low_freq, float _low_gain, float _high_freq, float _high_gain, float sr)
+    {
+        lowcut.set_hp(_low_freq, sr);
+        highcut.set_lp(_high_freq, sr);
+        low_gain = _low_gain;
+        high_gain = _high_gain;
+    }
+};
+
 #if 0
 { to keep editor happy
 #endif
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 6c20017..278cc40 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -143,6 +143,10 @@ struct organ_enums
         par_polyphony,
         par_quadenv,
         par_pwhlrange,
+        par_bassfreq,
+        par_bassgain,
+        par_treblefreq,
+        par_treblegain,
         par_var_mapcurve,
         param_count
     };
diff --git a/src/calf/organ.h b/src/calf/organ.h
index 5c71c16..69066a8 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -89,6 +89,11 @@ struct organ_parameters {
     
     float pitch_bend_range;
     
+    float bass_freq;
+    float bass_gain;
+    float treble_freq;
+    float treble_gain;
+    
     float dummy_mapcurve;
     
     //////////////////////////////////////////////////////////////////////////
@@ -312,29 +317,13 @@ struct drawbar_organ: public dsp::basic_synth, public calf_plugins::organ_enums
     organ_parameters *parameters;
     percussion_voice percussion;
     organ_vibrato global_vibrato;
+    two_band_eq eq_l, eq_r;
     
      drawbar_organ(organ_parameters *_parameters)
     : parameters(_parameters)
     , percussion(_parameters) {
     }
-    void render_separate(float *output[], int nsamples)
-    {
-        float buf[4096][2];
-        dsp::zero(&buf[0][0], 2 * nsamples);
-        basic_synth::render_to(buf, nsamples);
-        if (dsp::fastf2i_drm(parameters->lfo_mode) == organ_voice_base::lfomode_global)
-        {
-            for (int i = 0; i < nsamples; i += 64)
-                global_vibrato.process(parameters, buf + i, std::min(64, nsamples - i), sample_rate);
-        }
-        if (percussion.get_active())
-            percussion.render_percussion_to(buf, nsamples);
-        float gain = parameters->master * (1.0 / 8);
-        for (int i=0; i<nsamples; i++) {
-            output[0][i] = gain*buf[i][0];
-            output[1][i] = gain*buf[i][1];
-        }
-    }
+    void render_separate(float *output[], int nsamples);
     dsp::voice *alloc_voice() {
         block_voice<organ_voice> *v = new block_voice<organ_voice>();
         v->parameters = parameters;
diff --git a/src/modules.cpp b/src/modules.cpp
index ac0c4a1..2c711f9 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -492,6 +492,11 @@ CALF_PORT_PROPS(organ) = {
 
     { 200,        0, 2400,   25, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "pbend_range", "PBend Range" },
     
+    { 80,       20, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "bass_freq", "Bass Freq" },
+    { 1,        0.1, 10,     0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "bass_gain", "Bass Gain" },
+    { 12000,     20, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "treble_freq", "Treble Freq" },
+    { 1,        0.1, 10,     0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "treble_gain", "Treble Gain" },
+
     { 0,          0,    0,    0, PF_STRING | PF_PROP_MSGCONTEXT, &organ_init_map_curve, "map_curve", "Key mapping curve" },
 };
 
diff --git a/src/organ.cpp b/src/organ.cpp
index 91f55c8..2a07aa1 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -830,3 +830,26 @@ void organ_audio_module::deactivate()
 {
     
 }
+
+void drawbar_organ::render_separate(float *output[], int nsamples)
+{
+    float buf[4096][2];
+    dsp::zero(&buf[0][0], 2 * nsamples);
+    basic_synth::render_to(buf, nsamples);
+    if (dsp::fastf2i_drm(parameters->lfo_mode) == organ_voice_base::lfomode_global)
+    {
+        for (int i = 0; i < nsamples; i += 64)
+            global_vibrato.process(parameters, buf + i, std::min(64, nsamples - i), sample_rate);
+    }
+    if (percussion.get_active())
+        percussion.render_percussion_to(buf, nsamples);
+    float gain = parameters->master * (1.0 / 8);
+    eq_l.set(parameters->bass_freq, parameters->bass_gain, parameters->treble_freq, parameters->treble_gain, sample_rate);
+    eq_r.copy_coeffs(eq_l);
+    for (int i=0; i<nsamples; i++) {
+        output[0][i] = gain*eq_l.process(buf[i][0]);
+        output[1][i] = gain*eq_r.process(buf[i][1]);
+    }
+    eq_l.sanitize();
+    eq_r.sanitize();
+}

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list