[SCM] calf/master: + Organ, RotarySpeaker: moved to "main" group (no longer needs --enable-experimental) + Organ: added percussion level (in dB) + Organ: made percussion decay time freely adjustable + Knob: draw focus rectangle properly + JACK Host: better plugin naming on buttons in main window

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


The following commit has been merged in the master branch:
commit aea158efc1fed70ed799da6333b7d05156758883
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sun Mar 16 23:25:10 2008 +0000

    + Organ, RotarySpeaker: moved to "main" group (no longer needs --enable-experimental)
    + Organ: added percussion level (in dB)
    + Organ: made percussion decay time freely adjustable
    + Knob: draw focus rectangle properly
    + JACK Host: better plugin naming on buttons in main window
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@132 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/audio_fx.h b/src/calf/audio_fx.h
index 8e31d0a..fad34aa 100644
--- a/src/calf/audio_fx.h
+++ b/src/calf/audio_fx.h
@@ -250,50 +250,6 @@ public:
     }
 };
 
-#if ENABLE_EXPERIMENTAL
-
-/**
- * This is crap, not really sounding like rotary speaker.
- * I needed it for tests, maybe I'll give it more time later.
- */
-template<class T>
-class rotary_speaker
-{
-    simple_delay<256,T> delay;
-    fixed_point<unsigned int, 20> phase, dphase;
-    T last;
-public:    
-    rotary_speaker() {
-        reset();
-    }
-    void reset() {
-        delay.reset();
-        dphase = 6.3/44100*4096;
-        phase = 0;
-        last = 0;
-    }
-    template<class InT>
-    void process(T *out, InT *in, int nsamples) {
-        for (int i=0; i<nsamples; i++) {
-            phase += dphase;
-
-            double sig = sin(double(phase)*2*M_PI/4096);
-            double v = 100+30*sig;
-            double fv = floor(v);
-            delay.Put(in[i]);
-            T fd, fd2, fd3; // signal from delay's output
-            int ifv = (int)fv;
-            delay.GetInterp(fd, ifv, v-fv);
-            delay.GetInterp(fd2, ifv+3, v-fv);
-            delay.GetInterp(fd3, ifv+4, v-fv);
-            out[i] = 0.25f * (in[i] + fd + (last - in[i])*(0.5+0.25*sig));
-            last = last * 0.9f + dsp_mono(fd2 * 0.25f + fd3 * 0.25f);
-        }
-    }
-};
-
-#endif
-
 /**
  * A classic allpass loop reverb with modulated allpass filter.
  * Just started implementing it, so there is no control over many
diff --git a/src/calf/giface.h b/src/calf/giface.h
index 2f85d95..e2930ea 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -122,6 +122,7 @@ struct plugin_ctl_iface
     virtual bool activate_preset(int bank, int program) = 0;
     virtual const char *get_name() = 0;
     virtual const char *get_id() = 0;
+    virtual const char *get_label() = 0;
     virtual int get_input_count()=0;
     virtual int get_output_count()=0;
     virtual bool get_midi()=0;
@@ -210,6 +211,10 @@ struct ladspa_instance: public Module, public plugin_ctl_iface
     {
         return Module::get_id();
     }
+    virtual const char *get_label()
+    {
+        return Module::get_label();
+    }
     virtual int get_input_count() { return Module::in_count; }
     virtual int get_output_count() { return Module::out_count; }
     virtual bool get_midi() { return Module::support_midi; }
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index 11f4877..8094432 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -404,6 +404,10 @@ public:
     {
         return Module::get_id();
     }
+    virtual const char *get_label()
+    {
+        return Module::get_label();
+    }
 };
 
 extern jack_host_base *create_jack_host(const char *name);
diff --git a/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index d0552d8..9cb5a1c 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -72,6 +72,10 @@ struct lv2_instance: public Module, public plugin_ctl_iface
     {
         return Module::get_id();
     }
+    virtual const char *get_label()
+    {
+        return Module::get_label();
+    }
     virtual int get_input_count() { return Module::in_count; }
     virtual int get_output_count() { return Module::out_count; }
     virtual bool get_midi() { return Module::support_midi; }
diff --git a/src/calf/modules.h b/src/calf/modules.h
index dda5669..720c020 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -71,6 +71,7 @@ public:
     }
     static const char *get_name() { return "amp"; }
     static const char *get_id() { return "amp"; }
+    static const char *get_label() { return "Amp"; }
 };
 
 class flanger_audio_module: public null_audio_module
@@ -142,6 +143,7 @@ public:
     }
     static const char *get_name() { return "flanger"; }
     static const char *get_id() { return "flanger"; }
+    static const char *get_label() { return "Flanger"; }
 };
 
 class reverb_audio_module: public null_audio_module
@@ -191,6 +193,7 @@ public:
     }
     static const char *get_name() { return "reverb"; }
     static const char *get_id() { return "reverb"; }
+    static const char *get_label() { return "Reverb"; }
 };
 
 class filter_audio_module: public null_audio_module
@@ -342,6 +345,7 @@ public:
     }
     static const char *get_id() { return "filter"; }
     static const char *get_name() { return "filter"; }
+    static const char *get_label() { return "Filter"; }
 };
 
 class vintage_delay_audio_module: public null_audio_module
@@ -454,6 +458,174 @@ public:
     }
     static const char *get_name() { return "vintage_delay"; }
     static const char *get_id() { return "vintagedelay"; }
+    static const char *get_label() { return "Vintage Delay"; }
+};
+
+class rotary_speaker_audio_module: public null_audio_module
+{
+public:
+    enum { par_speed, param_count };
+    enum { in_count = 2, out_count = 2, support_midi = true, rt_capable = true };
+    static const char *port_names[];
+    float *ins[in_count]; 
+    float *outs[out_count];
+    float *params[param_count];
+    double phase_l, dphase_l, phase_h, dphase_h;
+    int cos_l, sin_l, cos_h, sin_h;
+    dsp::simple_delay<4096, float> delay;
+    dsp::biquad<float> crossover1l, crossover1r, crossover2l, crossover2r;
+    dsp::simple_delay<8, float> phaseshift;
+    uint32_t srate;
+    int vibrato_mode;
+    static parameter_properties param_props[];
+    float mwhl_value, hold_value, aspeed_l, aspeed_h, dspeed;
+
+    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();
+    }
+    void params_changed() {
+        set_vibrato();
+    }
+    void activate() {
+        phase_h = phase_l = 0.f;
+        setup();
+    }
+    void deactivate() {
+    }
+    void set_vibrato()
+    {
+        vibrato_mode = fastf2i_drm(*params[par_speed]);
+        if (!vibrato_mode)
+            dspeed = -1;
+        else {
+            float speed = vibrato_mode - 1;
+            if (vibrato_mode == 3)
+                speed = hold_value;
+            if (vibrato_mode == 4)
+                speed = mwhl_value;
+            dspeed = (speed < 0.5f) ? 0 : 1;
+        }
+        update_speed();
+    }
+    void update_speed()
+    {
+        float speed_h = aspeed_h >= 0 ? (48 + (400-48) * aspeed_h) : (48 * (1 + aspeed_h));
+        float speed_l = aspeed_l >= 0 ? 40 + (342-40) * aspeed_l : (40 * (1 + aspeed_l));
+        dphase_h = speed_h / (60 * srate);
+        dphase_l = speed_l / (60 * srate);
+        cos_h = (int)(16384*16384*cos(dphase_h * 2 * PI));
+        sin_h = (int)(16384*16384*sin(dphase_h * 2 * PI));
+        cos_l = (int)(16384*16384*cos(dphase_l * 2 * PI));
+        sin_l = (int)(16384*16384*sin(dphase_l * 2 * PI));
+    }
+    static inline void update_euler(long long int &x, long long int &y, int dx, int dy)
+    {
+        long long int nx = (x * dx - y * dy) >> 28;
+        long long int ny = (x * dy + y * dx) >> 28;
+        x = nx;
+        y = ny;
+    }
+    inline bool update_speed(float &aspeed, float delta_decc, float delta_acc)
+    {
+        if (aspeed < dspeed) {
+            aspeed = min(dspeed, aspeed + delta_acc);
+            return true;
+        }
+        else if (aspeed > dspeed) 
+        {
+            aspeed = max(dspeed, aspeed - delta_decc);
+            return true;
+        }        
+        return false;
+    }
+    uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+    {
+        long long int xl0 = (int)(10000*16384*cos(phase_l * 2 * PI));
+        long long int yl0 = (int)(10000*16384*sin(phase_l * 2 * PI));
+        long long int xh0 = (int)(10000*16384*cos(phase_h * 2 * PI));
+        long long int yh0 = (int)(10000*16384*sin(phase_h * 2 * PI));
+        // printf("xl=%d yl=%d dx=%d dy=%d\n", (int)(xl0>>14), (int)(yl0 >> 14), cos_l, sin_l);
+        for (unsigned int i = 0; i < nsamples; i++) {
+            float in_l = ins[0][i + offset], in_r = ins[1][i + offset];
+            float in_mono = 0.5f * (in_l + in_r);
+            
+            // int xl = (int)(10000 * cos(phase_l)), yl = (int)(10000 * sin(phase_l));
+            //int xh = (int)(10000 * cos(phase_h)), yh = (int)(10000 * sin(phase_h));
+            int xl = xl0 >> 14, yl = yl0 >> 14;
+            int xh = xh0 >> 14, yh = yh0 >> 14;
+            update_euler(xl0, yl0, cos_l, sin_l);
+            // printf("xl=%d yl=%d xl'=%f yl'=%f\n", xl, yl, 16384*cos((phase_l + dphase_l * i) * 2 * PI), 16384*sin((phase_l + dphase_l * i) * 2 * PI));
+            update_euler(xh0, yh0, cos_h, sin_h);
+            
+            float out_hi_l = delay.get_interp_1616(500000 + 40 * xh) + 0.0001 * xh * delay.get_interp_1616(650000 - 40 * yh) - delay.get_interp_1616(800000 - 60 * xh);
+            float out_hi_r = delay.get_interp_1616(550000 - 48 * yh) - 0.0001 * yh * delay.get_interp_1616(700000 + 46 * xh) + delay.get_interp_1616(1000000 + 76 * yh);
+
+            float out_lo_l = 0.5f * in_mono - delay.get_interp_1616(400000 + 34 * xl) + delay.get_interp_1616(650000 - 18 * yl);
+            float out_lo_r = 0.5f * in_mono + delay.get_interp_1616(600000 - 50 * xl) - delay.get_interp_1616(900000 + 15 * yl);
+            
+            out_hi_l = crossover2l.process_d2(out_hi_l); // sanitize(out_hi_l);
+            out_hi_r = crossover2r.process_d2(out_hi_r); // sanitize(out_hi_r);
+            out_lo_l = crossover1l.process_d2(out_lo_l); // sanitize(out_lo_l);
+            out_lo_r = crossover1r.process_d2(out_lo_r); // sanitize(out_lo_r);
+            
+            float out_l = out_hi_l + out_lo_l;
+            float out_r = out_hi_r + out_lo_r;
+            
+            in_mono += 0.06f * (out_l + out_r);
+            sanitize(in_mono);
+            
+            outs[0][i + offset] = out_l * 0.5f;
+            outs[1][i + offset] = out_r * 0.5f;
+            delay.put(in_mono);
+        }
+        crossover1l.sanitize_d2();
+        crossover1r.sanitize_d2();
+        crossover2l.sanitize_d2();
+        crossover2r.sanitize_d2();
+        phase_l = fmod(phase_l + nsamples * dphase_l, 1.0);
+        phase_h = fmod(phase_h + nsamples * dphase_h, 1.0);
+        float delta = nsamples * 1.0 / srate;
+        bool u1 = update_speed(aspeed_l, delta * 0.2, delta * 0.14);
+        bool u2 = update_speed(aspeed_h, delta, delta * 0.5);
+        if (u1 || u2)
+            set_vibrato();
+        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;
+        }
+    }
+    static const char *get_name() { return "rotary_speaker"; }
+    static const char *get_id() { return "rotaryspeaker"; }
+    static const char *get_label() { return "Rotary Speaker"; }
 };
 
 extern std::string get_builtin_modules_rdf();
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index b3fc394..4513856 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -23,228 +23,6 @@
 
 #if ENABLE_EXPERIMENTAL
 
-#include <assert.h>
-#include "biquad.h"
-#include "audio_fx.h"
-#include "synth.h"
-#include "organ.h"
-
-namespace synth {
-
-using namespace dsp;
-
-struct organ_audio_module: public null_audio_module, public drawbar_organ
-{
-public:
-    using drawbar_organ::note_on;
-    using drawbar_organ::note_off;
-    using drawbar_organ::control_change;
-    enum { par_drawbar1, par_drawbar2, par_drawbar3, par_drawbar4, par_drawbar5, par_drawbar6, par_drawbar7, par_drawbar8, par_drawbar9, par_foldover,
-        par_percmode, par_percharm, par_master, param_count };
-    enum { in_count = 0, out_count = 2, support_midi = true, rt_capable = true };
-    static const char *port_names[];
-    float *ins[in_count]; 
-    float *outs[out_count];
-    float *params[param_count];
-    organ_parameters par_values;
-    uint32_t srate;
-
-    organ_audio_module()
-    : drawbar_organ(&par_values)
-    {
-    }
-    static parameter_properties param_props[];
-    static const char *get_gui_xml();
-
-    void set_sample_rate(uint32_t sr) {
-        srate = sr;
-    }
-    void params_changed() {
-        for (int i = 0; i < param_count; i++)
-            ((float *)&par_values)[i] = *params[i];
-    }
-    void activate() {
-        setup(srate);
-    }
-    void deactivate() {
-    }
-    uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
-        float *o[2] = { outs[0] + offset, outs[1] + offset };
-        render_to(o, nsamples);
-        return 3;
-    }
-    static const char *get_name() { return "organ"; }    
-    static const char *get_id() { return "organ"; }    
-};
-
-class rotary_speaker_audio_module: public null_audio_module
-{
-public:
-    enum { par_speed, param_count };
-    enum { in_count = 2, out_count = 2, support_midi = true, rt_capable = true };
-    static const char *port_names[];
-    float *ins[in_count]; 
-    float *outs[out_count];
-    float *params[param_count];
-    double phase_l, dphase_l, phase_h, dphase_h;
-    int cos_l, sin_l, cos_h, sin_h;
-    dsp::simple_delay<4096, float> delay;
-    dsp::biquad<float> crossover1l, crossover1r, crossover2l, crossover2r;
-    dsp::simple_delay<8, float> phaseshift;
-    uint32_t srate;
-    int vibrato_mode;
-    static parameter_properties param_props[];
-    float mwhl_value, hold_value, aspeed_l, aspeed_h, dspeed;
-
-    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();
-    }
-    void params_changed() {
-        set_vibrato();
-    }
-    void activate() {
-        phase_h = phase_l = 0.f;
-        setup();
-    }
-    void deactivate() {
-    }
-    void set_vibrato()
-    {
-        vibrato_mode = fastf2i_drm(*params[par_speed]);
-        if (!vibrato_mode)
-            dspeed = -1;
-        else {
-            float speed = vibrato_mode - 1;
-            if (vibrato_mode == 3)
-                speed = hold_value;
-            if (vibrato_mode == 4)
-                speed = mwhl_value;
-            dspeed = (speed < 0.5f) ? 0 : 1;
-        }
-        update_speed();
-    }
-    void update_speed()
-    {
-        float speed_h = aspeed_h >= 0 ? (48 + (400-48) * aspeed_h) : (48 * (1 + aspeed_h));
-        float speed_l = aspeed_l >= 0 ? 40 + (342-40) * aspeed_l : (40 * (1 + aspeed_l));
-        dphase_h = speed_h / (60 * srate);
-        dphase_l = speed_l / (60 * srate);
-        cos_h = (int)(16384*16384*cos(dphase_h * 2 * PI));
-        sin_h = (int)(16384*16384*sin(dphase_h * 2 * PI));
-        cos_l = (int)(16384*16384*cos(dphase_l * 2 * PI));
-        sin_l = (int)(16384*16384*sin(dphase_l * 2 * PI));
-    }
-    static inline void update_euler(long long int &x, long long int &y, int dx, int dy)
-    {
-        long long int nx = (x * dx - y * dy) >> 28;
-        long long int ny = (x * dy + y * dx) >> 28;
-        x = nx;
-        y = ny;
-    }
-    inline bool update_speed(float &aspeed, float delta_decc, float delta_acc)
-    {
-        if (aspeed < dspeed) {
-            aspeed = min(dspeed, aspeed + delta_acc);
-            return true;
-        }
-        else if (aspeed > dspeed) 
-        {
-            aspeed = max(dspeed, aspeed - delta_decc);
-            return true;
-        }        
-        return false;
-    }
-    uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask)
-    {
-        long long int xl0 = (int)(10000*16384*cos(phase_l * 2 * PI));
-        long long int yl0 = (int)(10000*16384*sin(phase_l * 2 * PI));
-        long long int xh0 = (int)(10000*16384*cos(phase_h * 2 * PI));
-        long long int yh0 = (int)(10000*16384*sin(phase_h * 2 * PI));
-        // printf("xl=%d yl=%d dx=%d dy=%d\n", (int)(xl0>>14), (int)(yl0 >> 14), cos_l, sin_l);
-        for (unsigned int i = 0; i < nsamples; i++) {
-            float in_l = ins[0][i + offset], in_r = ins[1][i + offset];
-            float in_mono = 0.5f * (in_l + in_r);
-            
-            // int xl = (int)(10000 * cos(phase_l)), yl = (int)(10000 * sin(phase_l));
-            //int xh = (int)(10000 * cos(phase_h)), yh = (int)(10000 * sin(phase_h));
-            int xl = xl0 >> 14, yl = yl0 >> 14;
-            int xh = xh0 >> 14, yh = yh0 >> 14;
-            update_euler(xl0, yl0, cos_l, sin_l);
-            // printf("xl=%d yl=%d xl'=%f yl'=%f\n", xl, yl, 16384*cos((phase_l + dphase_l * i) * 2 * PI), 16384*sin((phase_l + dphase_l * i) * 2 * PI));
-            update_euler(xh0, yh0, cos_h, sin_h);
-            
-            float out_hi_l = delay.get_interp_1616(500000 + 40 * xh) + 0.0001 * xh * delay.get_interp_1616(650000 - 40 * yh) - delay.get_interp_1616(800000 - 60 * xh);
-            float out_hi_r = delay.get_interp_1616(550000 - 48 * yh) - 0.0001 * yh * delay.get_interp_1616(700000 + 46 * xh) + delay.get_interp_1616(1000000 + 76 * yh);
-
-            float out_lo_l = 0.5f * in_mono - delay.get_interp_1616(400000 + 34 * xl) + delay.get_interp_1616(650000 - 18 * yl);
-            float out_lo_r = 0.5f * in_mono + delay.get_interp_1616(600000 - 50 * xl) - delay.get_interp_1616(900000 + 15 * yl);
-            
-            out_hi_l = crossover2l.process_d2(out_hi_l); // sanitize(out_hi_l);
-            out_hi_r = crossover2r.process_d2(out_hi_r); // sanitize(out_hi_r);
-            out_lo_l = crossover1l.process_d2(out_lo_l); // sanitize(out_lo_l);
-            out_lo_r = crossover1r.process_d2(out_lo_r); // sanitize(out_lo_r);
-            
-            float out_l = out_hi_l + out_lo_l;
-            float out_r = out_hi_r + out_lo_r;
-            
-            in_mono += 0.06f * (out_l + out_r);
-            sanitize(in_mono);
-            
-            outs[0][i + offset] = out_l * 0.5f;
-            outs[1][i + offset] = out_r * 0.5f;
-            delay.put(in_mono);
-        }
-        crossover1l.sanitize_d2();
-        crossover1r.sanitize_d2();
-        crossover2l.sanitize_d2();
-        crossover2r.sanitize_d2();
-        phase_l = fmod(phase_l + nsamples * dphase_l, 1.0);
-        phase_h = fmod(phase_h + nsamples * dphase_h, 1.0);
-        float delta = nsamples * 1.0 / srate;
-        bool u1 = update_speed(aspeed_l, delta * 0.2, delta * 0.14);
-        bool u2 = update_speed(aspeed_h, delta, delta * 0.5);
-        if (u1 || u2)
-            set_vibrato();
-        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;
-        }
-    }
-    static const char *get_name() { return "rotary_speaker"; }
-    static const char *get_id() { return "rotaryspeaker"; }
-};
-
-};
-
 #endif
 
 #endif
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index 2f67bec..6998d97 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -27,6 +27,7 @@
 #include "inertia.h"
 #include "osc.h"
 #include "synth.h"
+#include "organ.h"
 
 namespace synth {
 
@@ -184,6 +185,55 @@ public:
     }
     static const char *get_name() { return "monosynth"; }
     static const char *get_id() { return "monosynth"; }
+    static const char *get_label() { return "Monosynth"; }
+};
+
+using namespace dsp;
+
+struct organ_audio_module: public null_audio_module, public drawbar_organ
+{
+public:
+    using drawbar_organ::note_on;
+    using drawbar_organ::note_off;
+    using drawbar_organ::control_change;
+    enum { par_drawbar1, par_drawbar2, par_drawbar3, par_drawbar4, par_drawbar5, par_drawbar6, par_drawbar7, par_drawbar8, par_drawbar9, par_foldover,
+        par_percdecay, par_perclevel, par_percharm, par_master, param_count };
+    enum { in_count = 0, out_count = 2, support_midi = true, rt_capable = true };
+    static const char *port_names[];
+    float *ins[in_count]; 
+    float *outs[out_count];
+    float *params[param_count];
+    organ_parameters par_values;
+    uint32_t srate;
+
+    organ_audio_module()
+    : drawbar_organ(&par_values)
+    {
+    }
+    static parameter_properties param_props[];
+    static const char *get_gui_xml();
+
+    void set_sample_rate(uint32_t sr) {
+        srate = sr;
+    }
+    void params_changed() {
+        for (int i = 0; i < param_count; i++)
+            ((float *)&par_values)[i] = *params[i];
+        update_params();
+    }
+    void activate() {
+        setup(srate);
+    }
+    void deactivate() {
+    }
+    uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
+        float *o[2] = { outs[0] + offset, outs[1] + offset };
+        render_to(o, nsamples);
+        return 3;
+    }
+    static const char *get_name() { return "organ"; }    
+    static const char *get_id() { return "organ"; }    
+    static const char *get_label() { return "Organ"; }    
 };
 
 };
diff --git a/src/calf/organ.h b/src/calf/organ.h
index 4276eea..9498c3b 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -30,12 +30,14 @@ namespace synth
 struct organ_parameters {
     float drawbars[9];
     float foldover;
-    float percussion_mode;
+    float percussion_time;
+    float percussion_level;
     float harmonic;
     float master;
+    
+    double perc_decay_const;
 
     inline bool get_foldover() { return foldover >= 0.5f; }
-    inline int get_percussion_mode() { return dsp::fastf2i_drm(percussion_mode); }
     inline int get_harmonic() { return dsp::fastf2i_drm(harmonic); }
 };
 
@@ -45,7 +47,7 @@ protected:
     dsp::sine_table<float, 4096, 1> sine_wave;
     dsp::fixed_point<int, 20> phase, dphase;
     int note;
-    dsp::decay<double> amp;
+    dsp::decay amp;
 
     inline float sine(dsp::fixed_point<int, 20> ph) {
         return ph.lerp_table_lookup_float(sine_wave.data);
@@ -163,16 +165,16 @@ public:
 
         if (!amp.get_active())
             return;
-        int mode = parameters->get_percussion_mode();
-        if (!mode)
+        if (parameters->percussion_level < small_value<float>())
             return;
         int harmonic = 2 * parameters->get_harmonic();
+        float level = parameters->percussion_level * (8 * 9);
         // XXXKF the decay needs work!
-        float age_const = mode == 1 ? 0.001f : 0.0003f;
+        double age_const = parameters->perc_decay_const;
         for (int i = 0; i < nsamples; i++) {
-            float osc = 0.5 * sine(harmonic * phase);
+            float osc = level * sine(harmonic * phase);
             buf[i] += osc * amp.get();
-            amp.age_exp(age_const, 0.0001f);
+            amp.age_exp(age_const, 1.0 / 32768.0);
             phase += dphase;
         }
     }
@@ -199,7 +201,7 @@ struct drawbar_organ: public synth::basic_synth {
         basic_synth::render_to(bufptr, nsamples);
         if (percussion.get_active())
             percussion.render_to(buf, nsamples);
-        float gain = parameters->master * 0.05;
+        float gain = parameters->master * (1.0 / (9 * 8));
         for (int i=0; i<nsamples; i++) {
             output[0][i] = gain*buf[i];
             output[1][i] = gain*buf[i];
@@ -214,6 +216,11 @@ struct drawbar_organ: public synth::basic_synth {
     virtual void setup(int sr) {
         basic_synth::setup(sr);
         percussion.setup(sr);
+        update_params();
+    }
+    void update_params()
+    {
+        parameters->perc_decay_const = dsp::decay::calc_exp_constant(1.0 / 1024.0, 0.001 * parameters->percussion_time * sample_rate);
     }
 };
 
diff --git a/src/calf/primitives.h b/src/calf/primitives.h
index 096f432..a7143bf 100644
--- a/src/calf/primitives.h
+++ b/src/calf/primitives.h
@@ -234,45 +234,63 @@ inline stereo_sample<T> lerp(stereo_sample<T> &v1, stereo_sample<T> &v2, float m
 /**
  * decay-only envelope (linear or exponential); deactivates itself when it goes below a set point (epsilon)
  */
-template<typename T>
 class decay
 {
-    T value, zero;
+    double value, initial;
+    unsigned int age, mask;
     bool active;
 public:
     decay() {
         active = false;
-        dsp::zero(zero);
+        mask = 127;
+        initial = value = 0.0;
     }
     inline bool get_active() {
         return active;
     }
-    inline T get() {
-        return active ? value : zero;
+    inline double get() {
+        return active ? value : 0.0;
     }
-    inline void set(const T &v) {
-        value = v;
+    inline void set(double v) {
+        initial = value = v;
         active = true;
+        age = 0;
     }
-    inline void add(const T &v) {
+    inline void add(double v) {
         if (active)
             value += v;
         else
             value = v;
+        initial = value;
+        age = 0;
         active = true;
     }
-    template<typename U>inline void age_exp(U constant, U epsilon) {
+    static inline double calc_exp_constant(double times, double cycles)
+    {
+        if (cycles < 1.0)
+            cycles = 1.0;
+        return pow(times, 1.0 / cycles);
+    }
+    inline void age_exp(double constant, double epsilon) {
         if (active) {
-            value *= (1.0-constant);
+            if (!(age & mask))
+                value = initial * pow(constant, (double)(age + 1));
+            else
+                value *= constant;
             if (value < epsilon)
                 active = false;
+            age++;
         }
     }
-    template<typename U>inline void age_lin(U constant, U epsilon) {
+    inline void age_lin(double constant, double epsilon) {
         if (active) {
-            value -= constant;
+            if (!(age & mask))
+                value = initial - constant * (age + 1);
+            else
+                value -= constant;
             if (value < epsilon)
                 active = false;
+            age++;
         }
     }
 };
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index ebaa80d..ce36d07 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -193,7 +193,6 @@ calf_vumeter_expose (GtkWidget *widget, GdkEventExpose *event)
     for (int x = ox; x <= ox + sx; x += 3)
     {
         float ts = (x - ox) * 1.0 / sx;
-        int is = vu->value > ts ? 2 : 1;
         float r, g, b;
         if (ts < 0.75)
             r = ts / 0.75, g = 1, b = 0;
@@ -201,7 +200,7 @@ calf_vumeter_expose (GtkWidget *widget, GdkEventExpose *event)
             r = 1, g = 1 - (ts - 0.75) / 0.25, b = 0;
         if (vu->value < ts || vu->value <= 0)
             r *= 0.5, g *= 0.5, b *= 0.5;
-        GdkColor sc2 = { 0, 65535 * r, 65535 * g, 65535 * b };
+        GdkColor sc2 = { 0, (guint16)(65535 * r), (guint16)(65535 * g), (guint16)(65535 * b) };
         gdk_cairo_set_source_color(c, &sc2);
         cairo_move_to(c, x, oy);
         cairo_line_to(c, x, oy + sy + 1);
@@ -341,7 +340,7 @@ calf_knob_expose (GtkWidget *widget, GdkEventExpose *event)
     // printf("exposed %p %d+%d\n", widget->window, widget->allocation.x, widget->allocation.y);
     if (gtk_widget_is_focus(widget))
     {
-        gtk_paint_focus(widget->style, window, GTK_STATE_NORMAL, NULL, widget, NULL, ox, oy, widget->allocation.width, widget->allocation.height);
+        gtk_paint_focus(widget->style, window, GTK_STATE_NORMAL, NULL, widget, NULL, ox, oy, 40, 40);
     }
     
     return TRUE;
diff --git a/src/dssigui.cpp b/src/dssigui.cpp
index e3995e2..4f03503 100644
--- a/src/dssigui.cpp
+++ b/src/dssigui.cpp
@@ -146,6 +146,10 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
     {
         return Module::get_id();
     }
+    virtual const char *get_label()
+    {
+        return Module::get_label();
+    }
     virtual int get_input_count() { return Module::in_count; }
     virtual int get_output_count() { return Module::out_count; }
     virtual bool get_midi() { return Module::support_midi; }
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index 3f55977..b62ee6b 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -56,11 +56,11 @@ jack_host_base *synth::create_jack_host(const char *effect_name)
         return new jack_host<monosynth_audio_module>();
     else if (!strcasecmp(effect_name, "vintagedelay"))
         return new jack_host<vintage_delay_audio_module>();
-#ifdef ENABLE_EXPERIMENTAL
     else if (!strcasecmp(effect_name, "organ"))
         return new jack_host<organ_audio_module>();
     else if (!strcasecmp(effect_name, "rotaryspeaker"))
         return new jack_host<rotary_speaker_audio_module>();
+#ifdef ENABLE_EXPERIMENTAL
 #endif
     else
         return NULL;
@@ -466,12 +466,6 @@ int main(int argc, char *argv[])
             sess.plugin_names.push_back(argv[optind++]);
         }
     }
-    /*
-    if (!sess.plugin_names.size()) {
-        print_help(argv);
-        return 0;
-    }
-    */
     try {
         global_presets.load_defaults();
     }
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index 6304fcd..9e7f6eb 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -117,6 +117,10 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
     {
         return Module::get_id();
     }
+    virtual const char *get_label()
+    {
+        return Module::get_label();
+    }
     virtual int get_input_count() { return Module::in_count; }
     virtual int get_output_count() { return Module::out_count; }
     virtual bool get_midi() { return Module::support_midi; }
@@ -135,11 +139,11 @@ plugin_proxy_base *create_plugin_proxy(const char *effect_name)
         return new plugin_proxy<monosynth_audio_module>();
     else if (!strcmp(effect_name, "VintageDelay"))
         return new plugin_proxy<vintage_delay_audio_module>();
-#ifdef ENABLE_EXPERIMENTAL
     else if (!strcmp(effect_name, "Organ"))
         return new plugin_proxy<organ_audio_module>();
     else if (!strcmp(effect_name, "RotarySpeaker"))
         return new plugin_proxy<rotary_speaker_audio_module>();
+#ifdef ENABLE_EXPERIMENTAL
 #endif
     else
         return NULL;
diff --git a/src/main_win.cpp b/src/main_win.cpp
index 661c389..a7318d0 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -188,7 +188,7 @@ main_window::plugin_strip *main_window::create_strip(plugin_ctl_iface *plugin)
     gtk_widget_show(sep);
     row++;
     
-    GtkWidget *label = gtk_toggle_button_new_with_label(plugin->get_name());
+    GtkWidget *label = gtk_toggle_button_new_with_label(plugin->get_label());
     gtk_table_attach(GTK_TABLE(strips_table), label, 0, 1, row, row + 2, ao, GTK_SHRINK, 0, 0);
     strip->name = label;
     gtk_signal_connect(GTK_OBJECT(label), "toggled", G_CALLBACK(gui_button_pressed), 
diff --git a/src/modules.cpp b/src/modules.cpp
index 8d83dbc..18dea2d 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -138,15 +138,18 @@ static synth::ladspa_info vintage_delay_info = { 0x8482, "VintageDelay", "Calf V
 ALL_WRAPPERS(vintage_delay)
 
 ////////////////////////////////////////////////////////////////////////////
-#ifdef ENABLE_EXPERIMENTAL
+
 static synth::ladspa_info rotary_speaker_info = { 0x8483, "RotarySpeaker", "Calf Rotary Speaker", "Krzysztof Foltman", copyright, "SimulationPlugin" };
 
 ALL_WRAPPERS(rotary_speaker)
 
+////////////////////////////////////////////////////////////////////////////
+
 static synth::ladspa_info organ_info = { 0x8481, "Organ", "Calf Organ", "Krzysztof Foltman", copyright, "SynthesizerPlugin" };
 
 ALL_WRAPPERS(organ)
 
+#ifdef ENABLE_EXPERIMENTAL
 #endif
 ////////////////////////////////////////////////////////////////////////////
 
@@ -167,9 +170,9 @@ const LV2_Descriptor *lv2_descriptor(uint32_t index)
         case 2: return &::lv2_reverb.descriptor;
         case 3: return &::lv2_vintage_delay.descriptor;
         case 4: return &::lv2_monosynth.descriptor;
-#ifdef ENABLE_EXPERIMENTAL
         case 5: return &::lv2_organ.descriptor;
         case 6: return &::lv2_rotary_speaker.descriptor;
+#ifdef ENABLE_EXPERIMENTAL
 #endif
         default: return NULL;
     }
@@ -188,8 +191,8 @@ const LADSPA_Descriptor *ladspa_descriptor(unsigned long Index)
         case 1: return &::ladspa_flanger.descriptor;
         case 2: return &::ladspa_reverb.descriptor;
         case 3: return &::ladspa_vintage_delay.descriptor;
-#ifdef ENABLE_EXPERIMENTAL
         case 4: return &::ladspa_rotary_speaker.descriptor;
+#ifdef ENABLE_EXPERIMENTAL
 #endif
         default: return NULL;
     }
@@ -208,9 +211,9 @@ const DSSI_Descriptor *dssi_descriptor(unsigned long Index)
         case 2: return &::ladspa_reverb.dssi_descriptor;
         case 3: return &::ladspa_monosynth.dssi_descriptor;
         case 4: return &::ladspa_vintage_delay.dssi_descriptor;
-#ifdef ENABLE_EXPERIMENTAL
         case 5: return &::ladspa_organ.dssi_descriptor;
         case 6: return &::ladspa_rotary_speaker.dssi_descriptor;
+#ifdef ENABLE_EXPERIMENTAL
 #endif
         default: return NULL;
     }
@@ -254,8 +257,6 @@ void synth::get_all_plugins(std::vector<giface_plugin_info> &plugins)
     plugins.push_back(create_plugin_info<reverb_audio_module>(reverb_info));
     plugins.push_back(create_plugin_info<monosynth_audio_module>(monosynth_info));
     plugins.push_back(create_plugin_info<vintage_delay_audio_module>(vintage_delay_info));
-#ifdef ENABLE_EXPERIMENTAL
     plugins.push_back(create_plugin_info<organ_audio_module>(organ_info));
     plugins.push_back(create_plugin_info<rotary_speaker_audio_module>(rotary_speaker_info));
-#endif
 }
diff --git a/src/organ.cpp b/src/organ.cpp
index b6f7da8..bee8941 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -20,8 +20,6 @@
  */
 #include <config.h>
 
-#if ENABLE_EXPERIMENTAL
-
 #include <assert.h>
 #include <memory.h>
 #include <complex>
@@ -45,12 +43,18 @@ const char *organ_audio_module::get_gui_xml()
                 "<align><toggle param=\"foldover\"/></align>"
             "</vbox>"
             "<vbox>"
-                "<label param=\"perc_mode\"/>"
-                "<combo param=\"perc_mode\"/>"
+                "<label param=\"perc_decay\"/>"
+                "<knob param=\"perc_decay\" expand=\"0\" fill=\"0\"/>"
+                "<value param=\"perc_decay\"/>"
             "</vbox>"
             "<vbox>"
-                "<label param=\"perc_hrm\"/>"
-                "<combo param=\"perc_hrm\"/>"
+                "<label param=\"perc_level\"/>"
+                "<knob param=\"perc_level\" expand=\"0\" fill=\"0\"/>"
+                "<value param=\"perc_level\"/>"
+            "</vbox>"        
+            "<vbox>"
+                "<label param=\"perc_harm\"/>"
+                "<combo param=\"perc_harm\"/>"
             "</vbox>"        
             "<vbox>"
                 "<label param=\"master\"/>"
@@ -101,7 +105,6 @@ const char *organ_audio_module::get_gui_xml()
 
 const char *organ_audio_module::port_names[] = {"Out L", "Out R"};
 
-const char *organ_percussion_mode_names[] = { "Off", "Short", "Long" };
 const char *organ_percussion_harmonic_names[] = { "2nd", "3rd" };
 
 parameter_properties organ_audio_module::param_props[] = {
@@ -116,8 +119,9 @@ parameter_properties organ_audio_module::param_props[] = {
     { 8,       0,  8, 80, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "h16", "1'" },
 
     { 1,         0,  1, 2, PF_BOOL | PF_CTL_TOGGLE, NULL, "foldover", "Foldover" },
-    { 1,         0,  2, 3, PF_ENUM | PF_CTL_COMBO, organ_percussion_mode_names, "perc_mode", "Perc. mode" },
-    { 3,         2,  3, 1, PF_ENUM | PF_CTL_COMBO, organ_percussion_harmonic_names, "perc_hrm", "Perc. harmonic" },
+    { 200,         10,  3000, 100, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "perc_decay", "Perc. decay" },
+    { 0.25,      0,  1, 100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL, "perc_level", "Perc. level" },
+    { 3,         2,  3, 1, PF_ENUM | PF_CTL_COMBO, organ_percussion_harmonic_names, "perc_harm", "Perc. harmonic" },
 
     { 0.1,         0,  1, 100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL, "master", "Volume" },
 };
@@ -131,5 +135,3 @@ const char *rotary_speaker_speed_names[] = { "Off", "Chorale", "Tremolo", "HoldP
 parameter_properties rotary_speaker_audio_module::param_props[] = {
     { 2,         0,  4, 1.01, PF_ENUM | PF_CTL_COMBO, rotary_speaker_speed_names, "vib_speed", "Speed Mode" },
 };
-
-#endif
diff --git a/src/synth.cpp b/src/synth.cpp
index 8e5b0ca..f622ef6 100644
--- a/src/synth.cpp
+++ b/src/synth.cpp
@@ -126,7 +126,7 @@ void basic_synth::control_change(int ctl, int val)
             control_change(64, 0);
         for (int i = 0; i < keystack.count(); i++)
             notes.push_back(keystack.nth(i));
-        for (int i = 0; i < notes.size(); i++)
+        for (int i = 0; i < (int)notes.size(); i++)
             note_off(notes[i], 0);
     }
     if (ctl == 121) { 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list