[SCM] calf/master: LFO module, Pulsator (GUI missing)

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


The following commit has been merged in the master branch:
commit 50797a4a7d57fc1fae2ceb55279a587e69604c71
Author: Markus Schmidt <schmidt at boomshop.net>
Date:   Sun Nov 15 06:39:45 2009 +0100

    LFO module, Pulsator (GUI missing)

diff --git a/gui/gui-equalizer8band.xml b/gui/gui-pulsator.xml
similarity index 100%
copy from gui/gui-equalizer8band.xml
copy to gui/gui-pulsator.xml
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 2ba9e02..48e8393 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -235,6 +235,16 @@ struct equalizer12band_metadata: public plugin_metadata<equalizer12band_metadata
     PLUGIN_NAME_ID_LABEL("equalizer12band", "equalizer12band", "Equalizer 12 Band")
 };
 
+/// Markus's Pulsator - metadata
+struct pulsator_metadata: public plugin_metadata<pulsator_metadata>
+{
+    enum { in_count = 2, out_count = 2, ins_optional = 0, outs_optional = 0, support_midi = false, require_midi = false, rt_capable = true };
+    enum { param_bypass, param_level_in, param_level_out, param_meter_inL, param_meter_inR,
+           param_meter_outL, param_meter_outR, param_clip_inL, param_clip_inR, param_clip_outL, param_clip_outR,
+           param_mode, param_freq, param_amount, param_offset, param_count };
+    PLUGIN_NAME_ID_LABEL("pulsator", "pulsator", "Pulsator")
+};
+
 /// 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
 struct organ_enums
diff --git a/src/calf/modulelist.h b/src/calf/modulelist.h
index 83c123c..0fbf487 100644
--- a/src/calf/modulelist.h
+++ b/src/calf/modulelist.h
@@ -16,6 +16,7 @@
     PER_MODULE_ITEM(equalizer5band, false, "equalizer5band")
     PER_MODULE_ITEM(equalizer8band, false, "equalizer8band")
     PER_MODULE_ITEM(equalizer12band, false, "equalizer12band")
+    PER_MODULE_ITEM(pulsator, false, "pulsator")
 #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 5f42b36..867a48f 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -1256,6 +1256,48 @@ public:
     int  get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline);
 };
 
+/// LFO by Markus
+class lfo_audio_module {
+private:
+    float phase, freq, offset;
+    int mode;
+    uint32_t srate;
+    bool is_active;
+public:
+    lfo_audio_module();
+    void set_params(float f, int m, float o, uint32_t sr);
+    float get_value();
+    void advance(uint32_t count);
+    void activate();
+    void deactivate();
+    virtual bool get_graph(int subindex, float *data, int points, cairo_iface *context);
+    virtual bool get_dot(int subindex, float &x, float &y, int &size, cairo_iface *context);
+};
+
+/// Pulsator by Markus Schmidt
+class pulsator_audio_module: public audio_module<pulsator_metadata>, public frequency_response_line_graph  {
+private:
+    uint32_t clip_inL, clip_inR, clip_outL, clip_outR;
+    float meter_inL, meter_inR, meter_outL, meter_outR;
+    lfo_audio_module lfoL, lfoR;
+public:
+    float *ins[in_count];
+    float *outs[out_count];
+    float *params[param_count];
+    uint32_t srate;
+    bool is_active;
+    pulsator_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);
+    bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
+    bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context);
+    bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
+    int  get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline);
+};
+
 /// Filterclavier --- MIDI controlled filter by Hans Baier
 class filterclavier_audio_module: 
         public audio_module<filterclavier_metadata>, 
diff --git a/src/modules.cpp b/src/modules.cpp
index 77c0eac..b45a453 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -307,13 +307,13 @@ CALF_PORT_PROPS(multibandcompressor) = {
     { 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" },
     
-    { -0.17,      -0.5,         0.5,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep0", "S0" },
-    { -0.17,      -0.5,         0.5,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep1", "S1" },
-    { -0.17,      -0.5,         0.5,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep2", "S2" },
+    { -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" },
+    { -0.17,      -0.5,         0.5,   0,  PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep2", "S3" },
     
-    { 0.895025,    0.25,        4,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q0", "Q0" },
-    { 0.895025,    0.25,        4,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q1", "Q1" },
-    { 0.895025,    0.25,        4,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q2", "Q2" },
+    { 0.895025,    0.25,        4,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q0", "Q1" },
+    { 0.895025,    0.25,        4,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q1", "Q2" },
+    { 0.895025,    0.25,        4,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q2", "Q3" },
     
     
     { 0.0625,      0.000976563, 1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "threshold0", "Threshold 1" },
@@ -563,6 +563,32 @@ CALF_PLUGIN_INFO(equalizer12band) = { 0x8501, "Equalizer12Band", "Calf Equalizer
 
 ////////////////////////////////////////////////////////////////////////////
 
+CALF_PORT_NAMES(pulsator) = {"In L", "In R", "Out L", "Out R"};
+
+const char *pulsator_mode_names[] = { "Sine", "Triangle", "Square", "Saw up", "Saw down" };
+
+CALF_PORT_PROPS(pulsator) = {
+    { 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" },
+    { 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_inL", "InL" },
+    { 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_inR", "InR" },
+    { 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_outL", "OutL" },
+    { 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_outR", "OutR" },
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inL", "0dB-InL" },
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inR", "0dB-InR" },
+    { 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" },
+    { 0,      0,  4,    0, PF_ENUM | PF_CTL_COMBO, pulsator_mode_names, "mode", "Mode" },
+    { 1,   0.01,   100, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "freq", "Frequency" },
+    { 0,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "amount", "Modulation" },
+    { 0,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "offset", "Offset L/R" },
+};
+
+CALF_PLUGIN_INFO(pulsator) = { 0x8502, "Pulsator", "Calf Pulsator", "Markus Schmidt", calf_plugins::calf_copyright_info, "ModulationPlugin" };
+
+////////////////////////////////////////////////////////////////////////////
+
 ////////////////////////////////////////////////////////////////////////////
 
 CALF_PORT_NAMES(monosynth) = {
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index 79a0be0..fef86b0 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -2893,3 +2893,286 @@ int equalizer5band_audio_module::get_changed_offsets(int index, int generation,
     }
     return false;
 }
+
+/// LFO module by Markus
+/// This module provides simple LFO's (sine=0, triangle=1, square=2, saw_up=3, saw_down=4)
+/// get_value() returns a value between -1 and 1
+////////////////////////////////////////////////////////////////////////////////
+lfo_audio_module::lfo_audio_module()
+{
+    is_active       = false;
+    phase = 0.f;
+}
+
+void lfo_audio_module::activate()
+{
+    is_active = true;
+    phase = 0.f;
+}
+
+void lfo_audio_module::deactivate()
+{
+    is_active = false;
+}
+
+float lfo_audio_module::get_value()
+{
+    float val = 0.f;
+    float ph = phase + offset;
+    if (ph >= 1.0)
+        ph = fmod(ph, 1.f);
+    switch (mode) {
+        default:
+        case 0:
+            // sine
+            val = sin(ph * 360.f);
+            break;
+        case 1:
+            // triangle
+            if(ph > 0.75)
+                val = (ph - 0.75) * 4 - 1;
+            else if(ph > 0.5)
+                val = (ph - 0.5) * 4 * -1;
+            else if(ph > 0.25)
+                val = 1 - (ph - 0.25) * 4;
+            else
+                val = ph * 4;
+            break;
+        case 2:
+            // square
+            val = (ph < 0.f) ? -1 : +1;
+            break;
+        case 3:
+            // saw up
+                val = ph * 2.f - 1;
+            break;
+        case 4:
+            // saw down
+            val = 1 - ph * 2.f;
+            break;
+    }
+    return val;
+}
+
+void lfo_audio_module::advance(uint32_t count)
+{
+    phase += count * freq * srate;
+    if (phase >= 1.0)
+        phase = fmod(phase, 1.f);
+}
+
+void lfo_audio_module::set_params(float f, int m, float o, uint32_t sr)
+{
+    // freq: a value in Hz
+    // mode: sine=0, triangle=1, square=2, saw_up=3, saw_down=4
+    // offset: value between 0.f and 1.f to offset the lfo in time
+    freq = f;
+    mode = m;
+    offset = o;
+    srate = sr;
+}
+
+bool lfo_audio_module::get_graph(int subindex, float *data, int points, cairo_iface *context)
+{
+    if (!is_active)
+        return false;
+    return true;
+}
+
+bool lfo_audio_module::get_dot(int subindex, float &x, float &y, int &size, cairo_iface *context)
+{
+    if (!is_active)
+        return false;
+    return false;
+}
+
+/// Pulsator by Markus Schmidt
+///
+/// This module provides a couple
+/// of different LFO's for modulating the level of a signal.
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+pulsator_audio_module::pulsator_audio_module()
+{
+    is_active = false;
+    srate = 0;
+    clip_inL    = 0.f;
+    clip_inR    = 0.f;
+    clip_outL   = 0.f;
+    clip_outR   = 0.f;
+    meter_inL  = 0.f;
+    meter_inR  = 0.f;
+    meter_outL = 0.f;
+    meter_outR = 0.f;
+}
+
+void pulsator_audio_module::activate()
+{
+    is_active = true;
+    lfoL.activate();
+    lfoR.activate();
+    params_changed();
+}
+void pulsator_audio_module::deactivate()
+{
+    is_active = false;
+    lfoL.deactivate();
+    lfoR.deactivate();
+}
+
+void pulsator_audio_module::params_changed()
+{
+    lfoL.set_params(*params[param_freq], *params[param_mode], 0.f, srate);
+    lfoR.set_params(*params[param_freq], *params[param_mode], *params[param_offset], srate);
+}
+
+void pulsator_audio_module::set_sample_rate(uint32_t sr)
+{
+    srate = sr;
+}
+
+uint32_t pulsator_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) {
+            outs[0][offset] = ins[0][offset];
+            outs[1][offset] = ins[1][offset];
+            ++offset;
+        }
+        // displays, too
+        clip_inL    = 0.f;
+        clip_inR    = 0.f;
+        clip_outL   = 0.f;
+        clip_outR   = 0.f;
+        meter_inL  = 0.f;
+        meter_inR  = 0.f;
+        meter_outL = 0.f;
+        meter_outR = 0.f;
+    } else {
+        
+        clip_inL    -= std::min(clip_inL,  numsamples);
+        clip_inR    -= std::min(clip_inR,  numsamples);
+        clip_outL   -= std::min(clip_outL, numsamples);
+        clip_outR   -= std::min(clip_outR, numsamples);
+        meter_inL = 0.f;
+        meter_inR = 0.f;
+        meter_outL = 0.f;
+        meter_outR = 0.f;
+        
+        // process
+        while(offset < numsamples) {
+            // cycle through samples
+            float outL = 0.f;
+            float outR = 0.f;
+            float inL = ins[0][offset];
+            float inR = ins[1][offset];
+            // in level
+            inR *= *params[param_level_in];
+            inL *= *params[param_level_in];
+            
+            float procL = inL;
+            float procR = inR;
+            
+            
+            
+            
+            // send to output
+            outs[0][offset] = outL;
+            outs[1][offset] = outR;
+            
+            // clip LED's
+            if(inL > 1.f) {
+                clip_inL  = srate >> 3;
+            }
+            if(inR > 1.f) {
+                clip_inR  = srate >> 3;
+            }
+            if(outL > 1.f) {
+                clip_outL = srate >> 3;
+            }
+            if(outR > 1.f) {
+                clip_outR = srate >> 3;
+            }
+            // set up in / out meters
+            if(inL > meter_inL) {
+                meter_inL = inL;
+            }
+            if(inR > meter_inR) {
+                meter_inR = inR;
+            }
+            if(outL > meter_outL) {
+                meter_outL = outL;
+            }
+            if(outR > meter_outR) {
+                meter_outR = outR;
+            }
+            
+            // next sample
+            ++offset;
+        } // cycle trough samples
+    }
+    // draw meters
+    if(params[param_clip_inL] != NULL) {
+        *params[param_clip_inL] = clip_inL;
+    }
+    if(params[param_clip_inR] != NULL) {
+        *params[param_clip_inR] = clip_inR;
+    }
+    if(params[param_clip_outL] != NULL) {
+        *params[param_clip_outL] = clip_outL;
+    }
+    if(params[param_clip_outR] != NULL) {
+        *params[param_clip_outR] = clip_outR;
+    }
+    
+    if(params[param_meter_inL] != NULL) {
+        *params[param_meter_inL] = meter_inL;
+    }
+    if(params[param_meter_inR] != NULL) {
+        *params[param_meter_inR] = meter_inR;
+    }
+    if(params[param_meter_outL] != NULL) {
+        *params[param_meter_outL] = meter_outL;
+    }
+    if(params[param_meter_outR] != NULL) {
+        *params[param_meter_outR] = meter_outR;
+    }
+    // whatever has to be returned x)
+    return outputs_mask;
+}
+bool pulsator_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
+{
+    if (!is_active) {
+        return false;
+    } else {
+        return false;
+    }
+}
+bool pulsator_audio_module::get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context)
+{
+    if (!is_active) {
+        return false;
+    } else {
+        return false;
+    }
+}
+bool pulsator_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
+{
+    if (!is_active) {
+        return false;
+    } else {
+        return false;
+    }
+}
+
+int pulsator_audio_module::get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline)
+{
+    if (!is_active) {
+        return false;
+    } else {
+        return false;
+    }
+}

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list