[SCM] calf/master: + Knob: better mousewheel support (also related changes in parameters in all modules) + Monosynth: fixed "high notes causing crash" bug + updated ChangeLog

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:36:55 UTC 2013


The following commit has been merged in the master branch:
commit 845ed1bd30c8f3bbe5f4f897ad3705c609e74d45
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sun Jan 6 20:51:20 2008 +0000

    + Knob: better mousewheel support (also related changes in parameters in all modules)
    + Monosynth: fixed "high notes causing crash" bug
    + updated ChangeLog
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@80 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/ChangeLog b/ChangeLog
index a84aaac..9d128f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Version 0.0.10
+
++ First attempt at DSSI GUI, does not support some features from JACK host,
+  but that's inevitable because of API limitations
++ Reverb: improvements (more parameters, fixed denormals)
++ Knob: added custom support for scroll wheel (instead of one inherited from
+GtkRange)
+
 Version 0.0.9
 
 + started creating an XML-based GUI
diff --git a/src/calf/giface.h b/src/calf/giface.h
index ec16edf..228fcce 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -99,6 +99,7 @@ struct parameter_properties
     float to_01(float value) const;
     std::string to_string(float value) const;
     int get_char_count() const;
+    float get_increment() const;
 };
 
 struct line_graph_iface
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index c26f7c3..17e17c9 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -136,7 +136,7 @@ calf_knob_expose (GtkWidget *widget, GdkEventExpose *event)
     ox += (widget->allocation.width - 40) / 2;
     oy += (widget->allocation.height - 40) / 2;
     
-    int phase = (adj->value - adj->lower) * 64 / (adj->upper - adj->lower);
+    int phase = (int)((adj->value - adj->lower) * 64 / (adj->upper - adj->lower));
     if (self->knob_type == 1 && phase == 32) {
         double pt = (adj->value - adj->lower) * 2.0 / (adj->upper - adj->lower) - 1.0;
         if (pt < 0)
@@ -196,6 +196,34 @@ calf_knob_pointer_motion (GtkWidget *widget, GdkEventMotion *event)
     return FALSE;
 }
 
+static gboolean
+calf_knob_scroll (GtkWidget *widget, GdkEventScroll *event)
+{
+    g_assert(CALF_IS_KNOB(widget));
+    CalfKnob *self = CALF_KNOB(widget);
+    GtkAdjustment *adj = gtk_range_get_adjustment(GTK_RANGE(widget));
+    
+    float oldvalue = adj->value;
+
+    float halfrange = (adj->upper + adj->lower) / 2;
+    int oldstep = (int)(0.5f + (adj->value - adj->lower) / adj->step_increment);
+    int step;
+    int nsteps = (int)(0.5f + (adj->upper - adj->lower) / adj->step_increment); // less 1 actually
+    if (event->direction)
+        step = oldstep - 1;
+    else
+        step = oldstep + 1;
+    
+    // trying to reduce error cumulation here, by counting from lowest or from highest
+    float value = adj->lower + step * adj->step_increment;
+    if (step >= nsteps / 2)
+        value = adj->upper - (nsteps - step) * adj->step_increment;
+    gtk_range_set_value(GTK_RANGE(widget), value);
+    // printf("step %d:%d nsteps %d value %f:%f\n", oldstep, step, nsteps, oldvalue, value);
+        
+    return FALSE;
+}
+
 static void
 calf_knob_class_init (CalfKnobClass *klass)
 {
@@ -206,6 +234,7 @@ calf_knob_class_init (CalfKnobClass *klass)
     widget_class->button_press_event = calf_knob_button_press;
     widget_class->button_release_event = calf_knob_button_release;
     widget_class->motion_notify_event = calf_knob_pointer_motion;
+    widget_class->scroll_event = calf_knob_scroll;
     GError *error = NULL;
     klass->knob_image = gdk_pixbuf_new_from_file(PKGLIBDIR "/knob.png", &error);
     g_assert(klass->knob_image != NULL);
diff --git a/src/giface.cpp b/src/giface.cpp
index 919ee9a..68a47cd 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -59,7 +59,10 @@ float parameter_properties::from_01(float value01) const
     case PF_BOOL:
     case PF_ENUM:
     case PF_ENUM_MULTI:
-        value = (int)value;
+        if (value > 0)
+            value = (int)(value + 0.5);
+        else
+            value = (int)(value - 0.5);
         break;
     }
     return value;
@@ -88,6 +91,20 @@ float parameter_properties::to_01(float value) const
     }
 }
 
+float parameter_properties::get_increment() const
+{
+    float increment = 0.01;
+    if (step > 1)
+        increment = 1.0 / (step - 1);
+    else 
+    if (step > 0 && step < 1)
+        increment = step;
+    else
+    if ((flags & PF_TYPEMASK) != PF_FLOAT)
+        increment = 1.0 / (max - min);
+    return increment;
+}
+
 int parameter_properties::get_char_count() const
 {
     if ((flags & PF_SCALEMASK) == PF_SCALE_PERC)
diff --git a/src/gui.cpp b/src/gui.cpp
index 3dafbed..47ed532 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -256,8 +256,9 @@ GtkWidget *knob_param_control::create(plugin_gui *_gui, int _param_no)
     gui = _gui;
     param_no = _param_no;
     const parameter_properties &props = get_props();
-    
-    widget = phat_knob_new_with_range (props.to_01 (gui->plugin->get_param_value(param_no)), 0, 1, 0.01);
+
+    float increment = props.get_increment();
+    widget = phat_knob_new_with_range (props.to_01 (gui->plugin->get_param_value(param_no)), 0, 1, increment);
     gtk_widget_set_size_request(widget, 50, 50);
     gtk_signal_connect(GTK_OBJECT(widget), "value-changed", G_CALLBACK(knob_value_changed), (gpointer)this);
     return widget;
@@ -269,10 +270,12 @@ GtkWidget *knob_param_control::create(plugin_gui *_gui, int _param_no)
 {
     gui = _gui;
     param_no = _param_no;
-    // const parameter_properties &props = get_props();
+    const parameter_properties &props = get_props();
     
     //widget = calf_knob_new_with_range (props.to_01 (gui->plugin->get_param_value(param_no)), 0, 1, 0.01);
     widget = calf_knob_new();
+    float increment = props.get_increment();
+    gtk_range_get_adjustment(GTK_RANGE(widget))->step_increment = increment;
     CALF_KNOB(widget)->knob_type = get_int("type");
     gtk_signal_connect(GTK_OBJECT(widget), "value-changed", G_CALLBACK(knob_value_changed), (gpointer)this);
     return widget;
@@ -594,7 +597,7 @@ void plugin_gui::xml_element_start(const char *element, const char *attributes[]
         if (!xam.count("cond") || xam["cond"].empty())
             g_error("Incorrect <if cond=\"[!]symbol\"> element");
         string cond = xam["cond"];
-        int exp_count = 1;
+        unsigned int exp_count = 1;
         if (cond.substr(0, 1) == "!") {
             exp_count = 0;
             cond.erase(0, 1);
diff --git a/src/modules.cpp b/src/modules.cpp
index 471cdaf..a840190 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -48,10 +48,10 @@ static synth::ladspa_wrapper<amp_audio_module> amp(amp_info);
 const char *flanger_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R"};
 
 parameter_properties flanger_audio_module::param_props[] = {
-    { 0.1,      0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "min_delay", "Minimum delay" },
-    { 0.5,      0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "mod_depth", "Modulation depth" },
-    { 0.25,    0.01, 20, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "mod_rate", "Modulation rate" },
-    { 0.90,   -0.99, 0.99, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "feedback", "Feedback" },
+    { 0.1,      0.1, 10,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "min_delay", "Minimum delay" },
+    { 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" },
     { 1, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
 };
 
@@ -68,10 +68,10 @@ const char *reverb_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R
 const char *reverb_room_sizes[] = { "Small", "Medium", "Large", "Tunnel-like" };
 
 parameter_properties reverb_audio_module::param_props[] = {
-    { 1.5,      0.5, 15.0, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "decay_time", "Decay time" },
-    { 5000,    2000,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hf_damp", "High Frq Damp" },
-    { 2,          0,    3, 1.01, PF_ENUM | PF_CTL_COMBO , reverb_room_sizes, "room_size", "Room size", },
-    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "diffusion", "Diffusion" },
+    { 1.5,      0.5, 15.0,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "decay_time", "Decay time" },
+    { 5000,    2000,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hf_damp", "High Frq Damp" },
+    { 2,          0,    3,    0, PF_ENUM | PF_CTL_COMBO , reverb_room_sizes, "room_size", "Room size", },
+    { 0.5,        0,    1,    0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "diffusion", "Diffusion" },
     { 0.25,       0,    2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
 };
 
@@ -95,7 +95,7 @@ const char *filter_choices[] = {
 };
 
 parameter_properties filter_audio_module::param_props[] = {
-    { 2000,      10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "freq", "Frequency" },
+    { 2000,      10,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "freq", "Frequency" },
     { 0.707,  0.707,   20,  1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "res", "Resonance" },
     { 0,          0,    5,    1, PF_ENUM | PF_CTL_COMBO, filter_choices, "mode", "Mode" },
     { 20,         5,  100,    1, PF_INT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "inertia", "Inertia"},
@@ -123,14 +123,14 @@ const char *vintage_delay_fbmodes[] = {
 };
 
 parameter_properties vintage_delay_audio_module::param_props[] = {
-    { 120,      30,    300, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_BPM, NULL, "bpm", "Tempo" },
+    { 120,      30,    300,   0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_BPM, NULL, "bpm", "Tempo" },
     {  4,        1,    16,    1, PF_INT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "subdiv", "Subdivide"},
     {  3,        1,    16,    1, PF_INT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "time_l", "Time L"},
     {  5,        1,    16,    1, PF_INT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "time_r", "Time R"},
-    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "feedback", "Feedback" },
-    { 0.25,       0,    2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
-    { 1,         0,  1, 1.01, PF_ENUM | PF_CTL_COMBO, vintage_delay_mixmodes, "mix_mode", "Mix mode" },
-    { 1,         0,  2, 1.01, PF_ENUM | PF_CTL_COMBO, vintage_delay_fbmodes, "medium", "Medium" },
+    { 0.5,       0,    1,     0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "feedback", "Feedback" },
+    { 0.25,      0,    2,   100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
+    { 1,         0,    1,     0, PF_ENUM | PF_CTL_COMBO, vintage_delay_mixmodes, "mix_mode", "Mix mode" },
+    { 1,         0,    2,     0, PF_ENUM | PF_CTL_COMBO, vintage_delay_fbmodes, "medium", "Medium" },
 };
 
 static synth::ladspa_info vintage_delay_info = { 0x8482, "VintageDelay", "Calf Vintage Delay", "Krzysztof Foltman", copyright, "DelayPlugin" };
diff --git a/src/monosynth.cpp b/src/monosynth.cpp
index a53b0d2..dc4a48d 100644
--- a/src/monosynth.cpp
+++ b/src/monosynth.cpp
@@ -188,31 +188,33 @@ static const char *monosynth_gui_xml =
 parameter_properties monosynth_audio_module::param_props[] = {
     { wave_saw,         0, wave_count - 1, 1, PF_ENUM | PF_CTL_COMBO, monosynth_waveform_names, "o1_wave", "Osc1 Wave" },
     { wave_sqr,         0, wave_count - 1, 1, PF_ENUM | PF_CTL_COMBO, monosynth_waveform_names, "o2_wave", "Osc2 Wave" },
-    { 10,         0,  100, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "o12_detune", "O1<>2 Detune" },
-    { 12,       -24,   24, 1.01, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_SEMITONES, NULL, "o2_xpose", "Osc 2 transpose" },
-    { 0,          0,    5, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_mode_names, "phase_mode", "Phase mode" },
-    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC, NULL, "o12_mix", "O1<>2 Mix" },
-    { 1,          0,    7, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_filter_choices, "filter", "Filter" },
-    { 33,        10,16000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "cutoff", "Cutoff" },
-    { 2,        0.7,    8, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL, "res", "Resonance" },
-    { 0,      -2400, 2400, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "filter_sep", "Separation" },
-    { 8000,  -10800,10800, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "env2cutoff", "Env->Cutoff" },
-    { 1,          0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "env2res", "Env->Res" },
-    { 1,          0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "env2amp", "Env->Amp" },
+    { 10,         0,  100,    0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "o12_detune", "O1<>2 Detune" },
+    { 12,       -24,   24,    0, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_SEMITONES, NULL, "o2_xpose", "Osc 2 transpose" },
+    { 0,          0,    5,    0, PF_ENUM | PF_CTL_COMBO, monosynth_mode_names, "phase_mode", "Phase mode" },
+    { 0.5,        0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "o12_mix", "O1<>2 Mix" },
+    { 1,          0,    7,    0, PF_ENUM | PF_CTL_COMBO, monosynth_filter_choices, "filter", "Filter" },
+    { 33,        10,16000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "cutoff", "Cutoff" },
+    { 2,        0.7,    8,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL, "res", "Resonance" },
+    { 0,      -2400, 2400,    0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "filter_sep", "Separation" },
+    { 8000,  -10800,10800,    0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "env2cutoff", "Env->Cutoff" },
+    { 1,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "env2res", "Env->Res" },
+    { 1,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "env2amp", "Env->Amp" },
     
-    { 1,          1,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_a", "Attack" },
-    { 350,       10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_d", "Decay" },
-    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr_s", "Sustain" },
-    { 50,       10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_r", "Release" },
+    { 1,          1,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_a", "Attack" },
+    { 350,       10,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_d", "Decay" },
+    { 0.5,        0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr_s", "Sustain" },
+    { 50,       10,20000,     0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_r", "Release" },
     
-    { 0,          0,    2, 1.01, PF_FLOAT | PF_SCALE_PERC, NULL, "key_follow", "Key Follow" },
-    { 0,          0,    3, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_legato_names, "legato", "Legato Mode" },
-    { 1,          1, 2000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "portamento", "Portamento" },
+    { 0,          0,    2,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "key_follow", "Key Follow" },
+    { 0,          0,    3,    0, PF_ENUM | PF_CTL_COMBO, monosynth_legato_names, "legato", "Legato Mode" },
+    { 1,          1, 2000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "portamento", "Portamento" },
     
     { 0.5,        0,    1,  0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "vel2filter", "Vel->Filter" },
     { 0,          0,    1,  0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "vel2amp", "Vel->Amp" },
 };
 
+float silence[2049];
+
 const char *monosynth_audio_module::get_gui_xml()
 {
     return monosynth_gui_xml;
@@ -441,6 +443,8 @@ void monosynth_audio_module::delayed_note_on()
     set_frequency();
     osc1.waveform = waves[wave1].get_level(osc1.phasedelta);
     osc2.waveform = waves[wave2].get_level(osc2.phasedelta);
+    if (!osc1.waveform) osc1.waveform = silence;
+    if (!osc2.waveform) osc2.waveform = silence;
     
     if (!running)
     {

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list