[SCM] calf/master: + Knob: added endless version, improved bipolar version + Phaser, Flanger, Organ: phase controls use endless knobs + update ChangeLog

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


The following commit has been merged in the master branch:
commit 11e2a336da3adfe83be28363eb469c7af6011bd3
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sat Jul 5 10:49:32 2008 +0000

    + Knob: added endless version, improved bipolar version
    + Phaser, Flanger, Organ: phase controls use endless knobs
    + update ChangeLog
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@227 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/ChangeLog b/ChangeLog
index 3fb8e27..02f2657 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 Version 0.0.14?
-+ OSC: totally new OSC wrapper, to allow for realtime-safe parsing
++ OSC: totally new OSC wrapper, to allow for realtime-safe parsing (doesn't
+  matter as far as functionality goes, will probably be rewritten again
+  anyway)
++ Everything: memory management fixes (should improve stability and
+  compatibility)
++ Organ: improved memory usage
++ GUI: improved bipolar knobs, added endless knobs
++ Presets: separate 'built-in' and 'user' presets (so that built-in presets
+  can be upgraded without affecting user's own presets)
 
 Version 0.0.13
 + Fixed several problems related to 64-bit environments and OpenSUSE (thanks
diff --git a/knob.png b/knob.png
index 436ce21..1047e49 100644
Binary files a/knob.png and b/knob.png differ
diff --git a/knobs/knob2.py b/knobs/knob2.py
index e3991b8..20870d3 100644
--- a/knobs/knob2.py
+++ b/knobs/knob2.py
@@ -17,58 +17,86 @@ arrow = WIDTH / 10
 phases = 65
 
 # Setup Cairo
-surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, phases * WIDTH, HEIGHT * 3)
+surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, phases * WIDTH, HEIGHT * 4)
 ctx = cairo.Context(surface)
 ctx.set_source_rgba(0.75, 0.75, 0.75, 0)
-ctx.rectangle(0, 0, phases * WIDTH, 3 * HEIGHT)
+ctx.rectangle(0, 0, phases * WIDTH, 4 * HEIGHT)
 ctx.fill()
 
-for variant in range(0, 3):
+for variant in range(0, 4):
     x = WIDTH / 2
     y = HEIGHT * (variant + 0.5)
     for phase in range(0, phases):
         # Draw out the triangle using absolute coordinates
         value = phase * 1.0 / (phases - 1)
-        sangle = (180-45)*pi/180
-        eangle = (360+45)*pi/180
+        if variant != 3:
+            sangle = (180 - 45)*pi/180
+            eangle = (360 + 45)*pi/180
+            nleds = 31
+        else:
+            sangle = (270)*pi/180
+            eangle = (270 + 360)*pi/180
+            nleds = 32
         vangle = sangle + value * (eangle - sangle)
         c, s = cos(vangle), sin(vangle)
 
-        nleds = 31
         midled = (nleds - 1) / 2
         midphase = (phases - 1) / 2
-        thresholdP = midled + 1 + ((phase - midphase - 1) * (nleds - midled - 2) / (phases - midphase - 2))
-        thresholdN = midled - 1 - ((midphase - 1 - phase) * (nleds - midled - 2) / (midphase - 1))
+        thresholdP = midled + 1 + ((phase - midphase - 1) * 1.0 * (nleds - midled - 2) / (phases - midphase - 2))
+        thresholdN = midled - 1 - ((midphase - 1 - phase) * 1.0 * (nleds - midled - 2) / (midphase - 1))
         
         spacing = pi / nleds
         for led in range(0, nleds):
-            adelta = (eangle - sangle - spacing) / (nleds - 1)
+            if variant == 3:
+                adelta = (eangle - sangle) / (nleds)
+            else:
+                adelta = (eangle - sangle - spacing) / (nleds - 1)
             lit = False
+            glowlit = False
+            glowval = 0.5
             hilite = False
             lvalue = led * 1.0 / (nleds - 1)
             pvalue = phase * 1.0 / (phases - 1)
+            if variant == 3: 
+                # XXXKF works only for phases = 2 * leds
+                exled = phase / 2.0
+                lit = led == exled or (phase == phases - 1 and led == 0)
+                glowlit = led == (exled + 0.5) or led == (exled - 0.5)
+                glowval = 0.8
+                hilite = (phase % ((phases - 1) / 4)) == 0
             if variant == 0: lit = (pvalue == 1.0) or pvalue > lvalue
             if variant == 1: 
                 if led == midled:
                     lit = (phase == midphase)
+                    #glowlit = (phase < midphase and thresholdN >= midled - 1) or (phase > midphase and thresholdP <= midled + 1)
+                    glowlit = False
                     hilite = True
                 elif led > midled and phase > midphase:
                     # led = [midled + 1, nleds - 1]
                     # phase = [midphase + 1, phases - 1]
                     lit = led <= thresholdP
+                    glowlit = led <= thresholdP + 1
+                    glowval = 0.4
                 elif led < midled and phase < midphase:
                     lit = led >= thresholdN
+                    glowlit = led >= thresholdN - 1
+                    glowval = 0.4
                 else:
                     lit = False
             if variant == 2: lit = pvalue == 0 or pvalue < lvalue
             if not lit:
-                ctx.set_source_rgb(0, 0, 0)
+                if not glowlit:
+                    ctx.set_source_rgb(0, 0, 0)
+                else:
+                    ctx.set_source_rgb(1 * glowval, 0.5 * glowval, 0)
             else:
                 if hilite:
                     ctx.set_source_rgb(1, 1, 0)
                 else:
                     ctx.set_source_rgb(1, 0.5, 0)
             ctx.set_line_width(3)
+            if hilite:
+                ctx.set_line_width(4)
             ctx.arc(x, y, radius, sangle + adelta * led, sangle + adelta * led + spacing)
             ctx.stroke()
 
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index 82afe45..b3d21cb 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -329,6 +329,7 @@ calf_knob_expose (GtkWidget *widget, GdkEventExpose *event)
     oy += (widget->allocation.height - 40) / 2;
     
     int phase = (int)((adj->value - adj->lower) * 64 / (adj->upper - adj->lower));
+    // skip middle phase except for true middle value
     if (self->knob_type == 1 && phase == 32) {
         double pt = (adj->value - adj->lower) * 2.0 / (adj->upper - adj->lower) - 1.0;
         if (pt < 0)
@@ -336,13 +337,16 @@ calf_knob_expose (GtkWidget *widget, GdkEventExpose *event)
         if (pt > 0)
             phase = 33;
     }
-    // the source code for the knob generator is on the old PC, so this hack is temporarily needed
-    // (avoid totally blank knob frames which say nothing about value polarity)
-    if (self->knob_type == 1) {
-        if (phase == 31 || phase == 30)
-            phase = 29;
-        if (phase == 33 || phase == 34)
-            phase = 35;
+    // endless knob: skip 90deg highlights unless the value is really a multiple of 90deg
+    if (self->knob_type == 3 && !(phase % 16)) {
+        if (phase == 64)
+            phase = 0;
+        double nom = adj->lower + phase * (adj->upper - adj->lower) / 64.0;
+        double diff = (adj->value - nom) / (adj->upper - adj->lower);
+        if (diff > 0.0001)
+            phase = (phase + 1) % 64;
+        if (diff < -0.0001)
+            phase = (phase + 63) % 64;
     }
     gdk_draw_pixbuf(GDK_DRAWABLE(widget->window), widget->style->fg_gc[0], CALF_KNOB_CLASS(GTK_OBJECT_GET_CLASS(widget))->knob_image, phase * 40, self->knob_type * 40, ox, oy, 40, 40, GDK_RGB_DITHER_NORMAL, 0, 0);
     // printf("exposed %p %d+%d\n", widget->window, widget->allocation.x, widget->allocation.y);
@@ -382,6 +386,10 @@ calf_knob_incr (GtkWidget *widget, int dir_down)
         step = oldstep - 1;
     else
         step = oldstep + 1;
+    if (self->knob_type == 3 && step >= nsteps)
+        step %= nsteps;
+    if (self->knob_type == 3 && step < 0)
+        step = nsteps - (nsteps - step) % nsteps;
     
     // trying to reduce error cumulation here, by counting from lowest or from highest
     float value = adj->lower + step * double(adj->upper - adj->lower) / nsteps;
@@ -445,6 +453,14 @@ calf_knob_button_release (GtkWidget *widget, GdkEventButton *event)
     return FALSE;
 }
 
+static inline float endless(float value)
+{
+    if (value >= 0)
+        return fmod(value, 1.f);
+    else
+        return fmod(1.f - fmod(1.f - value, 1.f), 1.f);
+}
+
 static gboolean
 calf_knob_pointer_motion (GtkWidget *widget, GdkEventMotion *event)
 {
@@ -452,7 +468,16 @@ calf_knob_pointer_motion (GtkWidget *widget, GdkEventMotion *event)
     CalfKnob *self = CALF_KNOB(widget);
 
     if (GTK_WIDGET_HAS_GRAB(widget)) 
-        gtk_range_set_value(GTK_RANGE(widget), self->start_value - (event->y - self->start_y) / 100);
+    {
+        if (self->knob_type == 3)
+        {
+            gtk_range_set_value(GTK_RANGE(widget), endless(self->start_value - (event->y - self->start_y) / 100));
+        }
+        else
+        {
+            gtk_range_set_value(GTK_RANGE(widget), self->start_value - (event->y - self->start_y) / 100);
+        }
+    }
     return FALSE;
 }
 
diff --git a/src/gui.cpp b/src/gui.cpp
index f7a4b62..163c027 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -445,6 +445,8 @@ GtkWidget *plugin_gui::create(plugin_ctl_iface *_plugin)
         else if ((props.flags & PF_CTLMASK) != PF_CTL_FADER)
         {
             params[i] = new knob_param_control();
+            if ((props.flags & PF_UNITMASK) == PF_UNIT_DEG)
+                params[i]->attribs["type"] = "3";
             widget = params[i]->create(this, i);
             gtk_table_attach (GTK_TABLE (container), widget, 1, 2, trow, trow + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
             gtk_table_attach (GTK_TABLE (container), params[i]->create_label(), 2, 3, trow, trow + 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), GTK_SHRINK, 0, 0);
diff --git a/src/modules.cpp b/src/modules.cpp
index cf08324..84bd118 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -56,7 +56,7 @@ 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, 360,   9, 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" },
 };
@@ -75,7 +75,7 @@ parameter_properties phaser_audio_module::param_props[] = {
     { 0.25,    0.01, 20,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "mod_rate", "Modulation rate" },
     { 0.25,   -0.99, 0.99,  0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "feedback", "Feedback" },
     { 6,          1, 12,   12, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB, NULL, "stages", "# Stages" },
-    { 180,        0, 360,  10, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_DEG, NULL, "stereo", "Stereo phase" },
+    { 180,        0, 360,   9, 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" },
 };
diff --git a/src/organ.cpp b/src/organ.cpp
index d04c14e..f1e4125 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -40,11 +40,11 @@ using namespace std;
             "<knob   attach-x=\"" no "\" attach-y=\"3\" param=\"f" no "\"/>" \
             "<value  attach-x=\"" no "\" attach-y=\"4\" param=\"f" no "\"/>" \
             "<combo  attach-x=\"" no "\" attach-y=\"5\" param=\"w" no "\"/>" \
-            "<knob   attach-x=\"" no "\" attach-y=\"6\" param=\"detune" no "\"/>" \
+            "<knob   attach-x=\"" no "\" attach-y=\"6\" param=\"detune" no "\" type=\"1\"/>" \
             "<value  attach-x=\"" no "\" attach-y=\"7\" param=\"detune" no "\"/>" \
-            "<knob   attach-x=\"" no "\" attach-y=\"8\" param=\"phase" no "\"/>" \
+            "<knob   attach-x=\"" no "\" attach-y=\"8\" param=\"phase" no "\" type=\"3\"/>" \
             "<value  attach-x=\"" no "\" attach-y=\"9\" param=\"phase" no "\"/>" \
-            "<knob   attach-x=\"" no "\" attach-y=\"10\" param=\"pan" no "\"/>" \
+            "<knob   attach-x=\"" no "\" attach-y=\"10\" param=\"pan" no "\" type=\"1\"/>" \
             "<value  attach-x=\"" no "\" attach-y=\"11\" param=\"pan" no "\"/>" \
             "<combo  attach-x=\"" no "\" attach-y=\"12\" param=\"routing" no "\"/>" 
 
@@ -283,7 +283,7 @@ const char *organ_audio_module::get_gui_xml()
                         "</vbox>"
                         "<vbox expand=\"0\" fill=\"0\">"
                             "<label param=\"vib_phase\" />"
-                            "<align><knob param=\"vib_phase\" expand=\"0\" fill=\"0\"/></align><value param=\"vib_phase\"/>"
+                            "<align><knob param=\"vib_phase\" expand=\"0\" fill=\"0\" type=\"3\"/></align><value param=\"vib_phase\"/>"
                         "</vbox>"
                         "<vbox expand=\"0\" fill=\"0\">"
                             "<label param=\"vib_mode\" />"

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list