[SCM] calf/master: + Plugins: move some non-inline functions out of modules.h to modules_dsp.cpp

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


The following commit has been merged in the master branch:
commit a13e1051f1efc366fbfa2fdeddc6dd984fc68629
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Nov 9 22:48:10 2008 +0000

    + Plugins: move some non-inline functions out of modules.h to modules_dsp.cpp

diff --git a/src/Makefile.am b/src/Makefile.am
index c0f369e..6306e56 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,7 +50,7 @@ calfbenchmark_CXXFLAGS = $(AM_CXXFLAGS) -DTEST_OSC
 calfbenchmark_LDADD += libcalfgui.la
 endif
 
-calf_la_SOURCES = modules.cpp modules_small.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp plugin.cpp preset.cpp synth.cpp utils.cpp
+calf_la_SOURCES = modules.cpp modules_dsp.cpp modules_small.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp plugin.cpp preset.cpp synth.cpp utils.cpp
 if USE_DEBUG
 calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat -disable-static
 else
@@ -66,7 +66,7 @@ calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat -export-
 endif
 endif
 
-libcalfstatic_la_SOURCES = modules.cpp modules_small.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp preset.cpp synth.cpp utils.cpp
+libcalfstatic_la_SOURCES = modules.cpp modules_dsp.cpp modules_small.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp preset.cpp synth.cpp utils.cpp
 libcalfstatic_la_LDFLAGS = -static -lexpat -disable-shared
 
 if USE_GUI
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 18be830..9018cb4 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -81,11 +81,7 @@ public:
     uint32_t srate;
     bool clear_reset;
     float last_r_phase;
-    void set_sample_rate(uint32_t sr) {
-        srate = sr;
-        left.setup(sr);
-        right.setup(sr);
-    }
+    void set_sample_rate(uint32_t sr);
     void params_changed() {
         float dry = 1.0;
         float wet = *params[par_amount];
@@ -120,30 +116,15 @@ public:
             clear_reset = false;
         }
     }
-    void activate() {
-        left.reset();
-        right.reset();
-        last_r_phase = *params[par_stereo] * (1.f / 360.f);
-        left.reset_phase(0.f);
-        right.reset_phase(last_r_phase);
-    }
-    void deactivate() {
-    }
+    void activate();
+    void deactivate();
     uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
         left.process(outs[0] + offset, ins[0] + offset, nsamples);
         right.process(outs[1] + offset, ins[1] + offset, nsamples);
         return outputs_mask; // XXXKF allow some delay after input going blank
     }
-    bool get_graph(int index, int subindex, float *data, int points, cairo_t *context)
-    {
-        if (index == par_delay && subindex < 2) 
-            return calf_plugins::get_graph(*this, subindex, data, points);
-        return false;
-    }
-    float freq_gain(int subindex, float freq, float srate)
-    {
-        return (subindex ? right : left).freq_gain(freq, srate);                
-    }
+    bool get_graph(int index, int subindex, float *data, int points, cairo_t *context);
+    float freq_gain(int subindex, float freq, float srate);
 };
 
 class phaser_audio_module: public audio_module<phaser_metadata>
@@ -156,11 +137,6 @@ public:
     bool clear_reset;
     float last_r_phase;
     dsp::simple_phaser<12> left, right;
-    void set_sample_rate(uint32_t sr) {
-        srate = sr;
-        left.setup(sr);
-        right.setup(sr);
-    }
     void params_changed() {
         float dry = 1.0;
         float wet = *params[par_amount];
@@ -197,15 +173,9 @@ public:
             clear_reset = false;
         }
     }
-    void activate() {
-        left.reset();
-        right.reset();
-        last_r_phase = *params[par_stereo] * (1.f / 360.f);
-        left.reset_phase(0.f);
-        right.reset_phase(last_r_phase);
-    }
-    void deactivate() {
-    }
+    void activate();
+    void set_sample_rate(uint32_t sr);
+    void deactivate();
     uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
         left.process(outs[0] + offset, ins[0] + offset, nsamples);
         right.process(outs[1] + offset, ins[1] + offset, nsamples);
@@ -231,16 +201,6 @@ public:
         reverb.set_cutoff(*params[par_hfdamp]);
         amount.set_inertia(*params[par_amount]);
     }
-    void activate() {
-        reverb.reset();
-    }
-    void deactivate() {
-    }
-    void set_sample_rate(uint32_t sr) {
-        srate = sr;
-        reverb.setup(sr);
-        amount.set_sample_rate(sr);
-    }
     uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
         numsamples += offset;
         for (uint32_t i = offset; i < numsamples; i++) {
@@ -254,6 +214,9 @@ public:
         reverb.extra_sanitize();
         return outputs_mask;
     }
+    void activate();
+    void set_sample_rate(uint32_t sr);
+    void deactivate();
 };
 
 class filter_audio_module: public audio_module<filter_metadata>, public line_graph_iface
@@ -317,20 +280,9 @@ public:
         inertia_resonance.step();
         calculate_filter();
     }
-    void activate() {
-        params_changed();
-        for (int i=0; i < order; i++) {
-            left[i].reset();
-            right[i].reset();
-        }
-        timer = once_per_n(srate / 1000);
-        timer.start();
-    }
-    void deactivate() {
-    }
-    void set_sample_rate(uint32_t sr) {
-        srate = sr;
-    }
+    void activate();
+    void set_sample_rate(uint32_t sr);
+    void deactivate();
     inline int process_channel(dsp::biquad_d1<float> *filter, float *in, float *out, uint32_t numsamples, int inmask) {
         if (inmask) {
             switch(order) {
@@ -399,19 +351,8 @@ public:
         }
         return ostate;
     }
-    bool get_graph(int index, int subindex, float *data, int points, cairo_t *context)
-    {
-        if (index == par_cutoff && !subindex) 
-            return calf_plugins::get_graph(*this, subindex, data, points);
-        return false;
-    }
-    float freq_gain(int subindex, float freq, float srate)
-    {
-        float level = 1.0;
-        for (int j = 0; j < order; j++)
-            level *= left[j].freq_gain(freq, srate);                
-        return level;
-    }
+    bool get_graph(int index, int subindex, float *data, int points, cairo_t *context);
+    float freq_gain(int subindex, float freq, float srate);
 };
 
 class vintage_delay_audio_module: public audio_module<vintage_delay_metadata>
@@ -548,36 +489,15 @@ public:
     /// Current rotation speed for treble rotor - manual mode
     float maspeed_h;
 
-    rotary_speaker_audio_module()
-    {
-        mwhl_value = hold_value = 0.f;
-        phase_h = phase_l = 0.f;
-        aspeed_l = 1.f;
-        aspeed_h = 1.f;
-        dspeed = 0.f;
-    }    
-    void set_sample_rate(uint32_t sr) {
-        srate = sr;
-        setup();
-    }
-    void setup()
-    {
-        crossover1l.set_lp_rbj(800.f, 0.7, (float)srate);
-        crossover1r.set_lp_rbj(800.f, 0.7, (float)srate);
-        crossover2l.set_hp_rbj(800.f, 0.7, (float)srate);
-        crossover2r.set_hp_rbj(800.f, 0.7, (float)srate);
-        set_vibrato();
-    }
+    rotary_speaker_audio_module();
+    void set_sample_rate(uint32_t sr);
+    void setup();
+    void activate();
+    void deactivate();
+    
     void params_changed() {
         set_vibrato();
     }
-    void activate() {
-        phase_h = phase_l = 0.f;
-        maspeed_h = maspeed_l = 0.f;
-        setup();
-    }
-    void deactivate() {
-    }
     void set_vibrato()
     {
         vibrato_mode = fastf2i_drm(*params[par_speed]);
@@ -695,21 +615,7 @@ public:
         }
         return outputs_mask;
     }
-    virtual void control_change(int ctl, int val)
-    {
-        if (vibrato_mode == 3 && ctl == 64)
-        {
-            hold_value = val / 127.f;
-            set_vibrato();
-            return;
-        }
-        if (vibrato_mode == 4 && ctl == 1)
-        {
-            mwhl_value = val / 127.f;
-            set_vibrato();
-            return;
-        }
-    }
+    virtual void control_change(int ctl, int val);
 };
 
 /// A multitap stereo chorus thing - processing
@@ -752,14 +658,6 @@ public:
             last_r_phase = r_phase;
         }
     }
-    void activate() {
-        params_changed();
-    }
-    void set_sample_rate(uint32_t sr) {
-        srate = sr;
-        left.setup(sr);
-        right.setup(sr);
-    }
     uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
         left.process(outs[0] + offset, ins[0] + offset, numsamples);
         right.process(outs[1] + offset, ins[1] + offset, numsamples);
@@ -769,16 +667,10 @@ public:
             *params[par_lfophase_r] = (double)right.lfo.phase * 360.0 / 4096.0;
         return outputs_mask; // XXXKF allow some delay after input going blank
     }
-    bool get_graph(int index, int subindex, float *data, int points, cairo_t *context)
-    {
-        if (index == par_delay && subindex < 2) 
-            return calf_plugins::get_graph(*this, subindex, data, points);
-        return false;
-    }
-    float freq_gain(int subindex, float freq, float srate)
-    {
-        return (subindex ? right : left).freq_gain(freq, srate);                
-    }
+    void activate();
+    void set_sample_rate(uint32_t sr);
+    bool get_graph(int index, int subindex, float *data, int points, cairo_t *context);
+    float freq_gain(int subindex, float freq, float srate);
 };
 
 extern std::string get_builtin_modules_rdf();
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
new file mode 100644
index 0000000..1628be1
--- /dev/null
+++ b/src/modules_dsp.cpp
@@ -0,0 +1,214 @@
+/* Calf DSP Library
+ * Example audio modules - DSP code
+ *
+ * Copyright (C) 2001-2008 Krzysztof Foltman
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <config.h>
+#include <assert.h>
+#include <memory.h>
+#if USE_JACK
+#include <jack/jack.h>
+#endif
+#include <calf/giface.h>
+#include <calf/modules.h>
+
+using namespace dsp;
+using namespace calf_plugins;
+
+void flanger_audio_module::activate() {
+    left.reset();
+    right.reset();
+    last_r_phase = *params[par_stereo] * (1.f / 360.f);
+    left.reset_phase(0.f);
+    right.reset_phase(last_r_phase);
+}
+
+void flanger_audio_module::set_sample_rate(uint32_t sr) {
+    srate = sr;
+    left.setup(sr);
+    right.setup(sr);
+}
+
+void flanger_audio_module::deactivate() {
+}
+
+bool flanger_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_t *context)
+{
+    if (index == par_delay && subindex < 2) 
+        return calf_plugins::get_graph(*this, subindex, data, points);
+    return false;
+}
+
+float flanger_audio_module::freq_gain(int subindex, float freq, float srate)
+{
+    return (subindex ? right : left).freq_gain(freq, srate);                
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+void phaser_audio_module::set_sample_rate(uint32_t sr)
+{
+    srate = sr;
+    left.setup(sr);
+    right.setup(sr);
+}
+
+void phaser_audio_module::activate()
+{
+    left.reset();
+    right.reset();
+    last_r_phase = *params[par_stereo] * (1.f / 360.f);
+    left.reset_phase(0.f);
+    right.reset_phase(last_r_phase);
+}
+
+void phaser_audio_module::deactivate()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+void reverb_audio_module::activate()
+{
+    reverb.reset();
+}
+
+void reverb_audio_module::deactivate()
+{
+}
+
+void reverb_audio_module::set_sample_rate(uint32_t sr)
+{
+    srate = sr;
+    reverb.setup(sr);
+    amount.set_sample_rate(sr);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+void filter_audio_module::activate()
+{
+    params_changed();
+    for (int i=0; i < order; i++) {
+        left[i].reset();
+        right[i].reset();
+    }
+    timer = once_per_n(srate / 1000);
+    timer.start();
+}
+
+void filter_audio_module::deactivate()
+{
+}
+
+void filter_audio_module::set_sample_rate(uint32_t sr)
+{
+    srate = sr;
+}
+
+bool filter_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_t *context)
+{
+    if (index == par_cutoff && !subindex) 
+        return calf_plugins::get_graph(*this, subindex, data, points);
+    return false;
+}
+
+float filter_audio_module::freq_gain(int subindex, float freq, float srate)
+{
+    float level = 1.0;
+    for (int j = 0; j < order; j++)
+        level *= left[j].freq_gain(freq, srate);                
+    return level;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+rotary_speaker_audio_module::rotary_speaker_audio_module()
+{
+    mwhl_value = hold_value = 0.f;
+    phase_h = phase_l = 0.f;
+    aspeed_l = 1.f;
+    aspeed_h = 1.f;
+    dspeed = 0.f;
+}    
+
+void rotary_speaker_audio_module::set_sample_rate(uint32_t sr)
+{
+    srate = sr;
+    setup();
+}
+
+void rotary_speaker_audio_module::setup()
+{
+    crossover1l.set_lp_rbj(800.f, 0.7, (float)srate);
+    crossover1r.set_lp_rbj(800.f, 0.7, (float)srate);
+    crossover2l.set_hp_rbj(800.f, 0.7, (float)srate);
+    crossover2r.set_hp_rbj(800.f, 0.7, (float)srate);
+    set_vibrato();
+}
+
+void rotary_speaker_audio_module::activate()
+{
+    phase_h = phase_l = 0.f;
+    maspeed_h = maspeed_l = 0.f;
+    setup();
+}
+
+void rotary_speaker_audio_module::deactivate()
+{
+}
+
+void rotary_speaker_audio_module::control_change(int ctl, int val)
+{
+    if (vibrato_mode == 3 && ctl == 64)
+    {
+        hold_value = val / 127.f;
+        set_vibrato();
+        return;
+    }
+    if (vibrato_mode == 4 && ctl == 1)
+    {
+        mwhl_value = val / 127.f;
+        set_vibrato();
+        return;
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+void multichorus_audio_module::activate() {
+    params_changed();
+}
+
+void multichorus_audio_module::set_sample_rate(uint32_t sr) {
+    srate = sr;
+    left.setup(sr);
+    right.setup(sr);
+}
+
+bool multichorus_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_t *context)
+{
+    if (index == par_delay && subindex < 2) 
+        return calf_plugins::get_graph(*this, subindex, data, points);
+    return false;
+}
+
+float multichorus_audio_module::freq_gain(int subindex, float freq, float srate)
+{
+    return (subindex ? right : left).freq_gain(freq, srate);                
+}

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list