[SCM] calf/master: + Flanger: added Stereo phase and Reset + GUI: added support for press buttons (like Reset) + JACK host: added support for autoreset parameters

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:04 UTC 2013


The following commit has been merged in the master branch:
commit 987165483173de3dcaa40d87b673190a9ddfb42a
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Wed Feb 13 23:10:19 2008 +0000

    + Flanger: added Stereo phase and Reset
    + GUI: added support for press buttons (like Reset)
    + JACK host: added support for autoreset parameters
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@129 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/audio_fx.h b/src/calf/audio_fx.h
index f950a08..8e31d0a 100644
--- a/src/calf/audio_fx.h
+++ b/src/calf/audio_fx.h
@@ -52,9 +52,9 @@ protected:
     int sample_rate, min_delay_samples, mod_depth_samples;
     float rate, wet, dry, min_delay, mod_depth, odsr;
     gain_smoothing gs_wet, gs_dry;
-    fixed_point<unsigned int, 20> phase, dphase;
     sine_table<int, 4096, 65536> sine;
 public:
+    fixed_point<unsigned int, 20> phase, dphase;
     float get_rate() {
         return rate;
     }
@@ -91,6 +91,14 @@ public:
         // 128 because it's then multiplied by (hopefully) a value of 32768..-32767
         this->mod_depth_samples = (int)(mod_depth * 32.0 * sample_rate);
     }
+    void reset_phase(float req_phase)
+    {
+        phase = req_phase * 4096.0;
+    }
+    void inc_phase(float req_phase)
+    {
+        phase += fixed_point<unsigned int, 20>(req_phase * 4096.0);
+    }
 };
 
 /**
diff --git a/src/calf/giface.h b/src/calf/giface.h
index 941c4a2..2f85d95 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -73,6 +73,7 @@ enum parameter_flags
   PF_CTL_TOGGLE = 0x03000,
   PF_CTL_COMBO = 0x04000,
   PF_CTL_RADIO = 0x05000,
+  PF_CTL_BUTTON = 0x06000,
   
   PF_CTLOPTIONS = 0xFF0000,
   PF_CTLO_HORIZ = 0x010000,
@@ -87,6 +88,7 @@ enum parameter_flags
   PF_UNIT_CENTS = 0x06000000,
   PF_UNIT_SEMITONES = 0x07000000,
   PF_UNIT_BPM = 0x08000000,
+  PF_UNIT_DEG = 0x09000000,
 };
 
 struct parameter_properties
diff --git a/src/calf/gui.h b/src/calf/gui.h
index fc0016e..7352778 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -160,6 +160,16 @@ struct toggle_param_control: public param_control
     static void toggle_value_changed(GtkCheckButton *widget, gpointer value);
 };
 
+struct button_param_control: public param_control
+{
+    GtkCheckButton *scale;
+
+    virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
+    virtual void get();
+    virtual void set();
+    static void button_clicked(GtkButton *widget, gpointer value);
+};
+
 struct combo_box_param_control: public param_control
 {
     GtkComboBox *scale;
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index 2b56bd9..e25b5f4 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -330,6 +330,7 @@ public:
             }
         }
         process_part(time, nframes - time);
+        module.params_reset();
         return 0;
     }
     
diff --git a/src/calf/modules.h b/src/calf/modules.h
index a9287cc..dda5669 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -39,6 +39,7 @@ public:
     inline void control_change(int controller, int value) {}
     inline void pitch_bend(int value) {} // -8192 to 8191
     inline void params_changed() {}
+    inline void params_reset() {}
     inline void activate() {}
     inline void deactivate() {}
     inline void set_sample_rate(uint32_t sr) { }
@@ -75,7 +76,7 @@ public:
 class flanger_audio_module: public null_audio_module
 {
 public:
-    enum { par_delay, par_depth, par_rate, par_fb, par_amount, param_count };
+    enum { par_delay, par_depth, par_rate, par_fb, par_stereo, par_reset, par_amount, param_count };
     enum { in_count = 2, out_count = 2, support_midi = false, rt_capable = true };
     static const char *port_names[];
     dsp::simple_flanger<float, 2048> left, right;
@@ -83,6 +84,8 @@ public:
     float *outs[out_count];
     float *params[param_count];
     uint32_t srate;
+    bool clear_reset;
+    float last_r_phase;
     static parameter_properties param_props[];
     void set_sample_rate(uint32_t sr) {
         srate = sr;
@@ -102,10 +105,33 @@ public:
         left.set_min_delay(min_delay); right.set_min_delay(min_delay);
         left.set_mod_depth(mod_depth); right.set_mod_depth(mod_depth);
         left.set_fb(fb); right.set_fb(fb);
+        float r_phase = *params[par_stereo] * (1.f / 360.f);
+        clear_reset = false;
+        if (*params[par_reset] >= 0.5) {
+            clear_reset = true;
+            left.reset_phase(0.f);
+            right.reset_phase(r_phase);
+        } else {
+            if (fabs(r_phase - last_r_phase) > 0.0001f) {
+                right.phase = left.phase;
+                right.inc_phase(r_phase);
+                last_r_phase = r_phase;
+            }
+        }
+    }
+    void params_reset()
+    {
+        if (clear_reset) {
+            *params[par_reset] = 0.f;
+            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() {
     }
diff --git a/src/giface.cpp b/src/giface.cpp
index 2360a05..1c213fa 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -156,6 +156,7 @@ std::string parameter_properties::to_string(float value) const
     case PF_UNIT_CENTS: return string(buf) + " ct";
     case PF_UNIT_SEMITONES: return string(buf) + "#";
     case PF_UNIT_BPM: return string(buf) + " bpm";
+    case PF_UNIT_DEG: return string(buf) + " deg";
     }
 
     return string(buf);
diff --git a/src/gui.cpp b/src/gui.cpp
index cbf13d1..a772c5b 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -257,6 +257,39 @@ void toggle_param_control::set()
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), (int)gui->plugin->get_param_value(param_no) - (int)props.min);
 }
 
+// button
+
+GtkWidget *button_param_control::create(plugin_gui *_gui, int _param_no)
+{
+    gui = _gui;
+    param_no = _param_no;
+    
+    widget  = gtk_button_new_with_label (get_props().name);
+    gtk_signal_connect (GTK_OBJECT (widget), "clicked", G_CALLBACK (button_clicked), (gpointer)this);
+    return widget;
+}
+
+void button_param_control::button_clicked(GtkButton *widget, gpointer value)
+{
+    param_control *jhp = (param_control *)value;
+    
+    jhp->get();
+}
+
+void button_param_control::get()
+{
+    const parameter_properties &props = get_props();
+    gui->set_param_value(param_no, props.max, this);
+}
+
+void button_param_control::set()
+{
+    _GUARD_CHANGE_
+    const parameter_properties &props = get_props();
+    if (gui->plugin->get_param_value(param_no) - props.min >= 0.5)
+        gtk_button_clicked (GTK_BUTTON (widget));
+}
+
 // knob
 
 GtkWidget *knob_param_control::create(plugin_gui *_gui, int _param_no)
@@ -370,10 +403,19 @@ GtkWidget *plugin_gui::create(plugin_ctl_iface *_plugin)
     for (int i = 0; i < param_count; i++) {
         int trow = i;
         parameter_properties &props = *plugin->get_param_props(i);
-        GtkWidget *label = gtk_label_new (props.name);
-        gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
-        gtk_table_attach (GTK_TABLE (container), label, 0, 1, trow, trow + 1, GTK_FILL, GTK_FILL, 2, 2);
         
+        GtkWidget *label = NULL;
+        bool use_label = true;
+        if ((props.flags & PF_TYPEMASK) == PF_BOOL && 
+            (props.flags & PF_CTLMASK) == PF_CTL_BUTTON)
+            use_label = false;
+        
+        if (use_label)
+        {
+            label = gtk_label_new (props.name);
+            gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+            gtk_table_attach (GTK_TABLE (container), label, 0, 1, trow, trow + 1, GTK_FILL, GTK_FILL, 2, 2);
+        }
         
         GtkWidget *widget = NULL;
         
@@ -391,6 +433,13 @@ GtkWidget *plugin_gui::create(plugin_ctl_iface *_plugin)
             widget = params[i]->create(this, i);
             gtk_table_attach (GTK_TABLE (container), widget, 1, 3, trow, trow + 1, GTK_EXPAND, GTK_SHRINK, 0, 0);
         }
+        else if ((props.flags & PF_TYPEMASK) == PF_BOOL && 
+                 (props.flags & PF_CTLMASK) == PF_CTL_BUTTON)
+        {
+            params[i] = new button_param_control();
+            widget = params[i]->create(this, i);
+            gtk_table_attach (GTK_TABLE (container), widget, 0, 3, trow, trow + 1, GTK_EXPAND, GTK_SHRINK, 0, 0);
+        }
         else if ((props.flags & PF_CTLMASK) != PF_CTL_FADER)
         {
             params[i] = new knob_param_control();
@@ -532,6 +581,8 @@ param_control *plugin_gui::create_control_from_xml(const char *element, const ch
         return new combo_box_param_control;
     if (!strcmp(element, "toggle"))
         return new toggle_param_control;
+    if (!strcmp(element, "button"))
+        return new button_param_control;
     if (!strcmp(element, "label"))
         return new label_param_control;
     if (!strcmp(element, "value"))
diff --git a/src/modules.cpp b/src/modules.cpp
index c9e1984..8d83dbc 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -56,6 +56,8 @@ parameter_properties flanger_audio_module::param_props[] = {
     { 0.5,      0.1, 10,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "mod_depth", "Modulation depth" },
     { 0.25,    0.01, 20,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "mod_rate", "Modulation rate" },
     { 0.90,   -0.99, 0.99,  0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "feedback", "Feedback" },
+    { 0,          0, 360,  10, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_DEG, NULL, "stereo", "Stereo phase" },
+    { 0,          0, 1,     2, PF_BOOL | PF_CTL_BUTTON , NULL, "reset", "Reset" },
     { 1,          0, 2,     0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
 };
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list