[SCM] calf/master: + Framework: add support for Rotations Per Minute unit + Rotary Speaker: added manual mode (both rotor speeds user-adjustable via control ports)

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


The following commit has been merged in the master branch:
commit f8269acaaf543746527805530800bb87a7afe00e
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Thu Aug 7 21:56:30 2008 +0000

    + Framework: add support for Rotations Per Minute unit
    + Rotary Speaker: added manual mode (both rotor speeds user-adjustable via control ports)
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@261 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/giface.h b/src/calf/giface.h
index a443fec..28567b7 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -94,6 +94,7 @@ enum parameter_flags
   PF_UNIT_BPM = 0x08000000,
   PF_UNIT_DEG = 0x09000000,
   PF_UNIT_NOTE = 0x0A000000,
+  PF_UNIT_RPM = 0x0B000000,
 };
 
 class null_audio_module;
diff --git a/src/calf/modules.h b/src/calf/modules.h
index c1e53bd..84680f6 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -573,21 +573,34 @@ public:
 class rotary_speaker_audio_module: public null_audio_module
 {
 public:
-    enum { par_speed, par_spacing, par_shift, par_moddepth, param_count };
+    enum { par_speed, par_spacing, par_shift, par_moddepth, par_treblespeed, par_bassspeed, 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];
-    unsigned int phase_l, dphase_l, phase_h, dphase_h;
+    /// Current phases and phase deltas for bass and treble rotors
+    uint32_t phase_l, dphase_l, phase_h, dphase_h;
     dsp::simple_delay<1024, 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;
-    unsigned int dphase2_l, dphase2_h;
+    /// Current CC1 (Modulation) value, normalized to [0, 1]
+    float mwhl_value;
+    /// Current CC64 (Hold) value, normalized to [0, 1]
+    float hold_value;
+    /// Current rotation speed for bass rotor - automatic mode
+    float aspeed_l;
+    /// Current rotation speed for treble rotor - automatic mode
+    float aspeed_h;
+    /// Desired speed (0=slow, 1=fast) - automatic mode
+    float dspeed;
+    /// Current rotation speed for bass rotor - manual mode
+    float maspeed_l;
+    /// Current rotation speed for treble rotor - manual mode
+    float maspeed_h;
 
     rotary_speaker_audio_module()
     {
@@ -614,6 +627,7 @@ public:
     }
     void activate() {
         phase_h = phase_l = 0.f;
+        maspeed_h = maspeed_l = 0.f;
         setup();
     }
     void deactivate() {
@@ -621,6 +635,9 @@ public:
     void set_vibrato()
     {
         vibrato_mode = fastf2i_drm(*params[par_speed]);
+        // manual vibrato - do not recalculate speeds as they're not used anyway
+        if (vibrato_mode == 5) 
+            return;
         if (!vibrato_mode)
             dspeed = -1;
         else {
@@ -633,14 +650,27 @@ public:
         }
         update_speed();
     }
+    /// Convert RPM speed to delta-phase
+    inline uint32_t rpm2dphase(float rpm)
+    {
+        return (uint32_t)((rpm / (60.0 * srate)) * (1 << 30)) << 2;
+    }
+    /// Set delta-phase variables based on current calculated (and interpolated) RPM 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));
-        double fdphase_h = speed_h / (60 * srate);
-        double fdphase_l = speed_l / (60 * srate);
-        dphase_h = (unsigned int)(fdphase_h * (1 << 30)) << 2;
-        dphase_l = (unsigned int)(fdphase_l * (1 << 30)) << 2;
+        dphase_h = rpm2dphase(speed_h);
+        dphase_l = rpm2dphase(speed_l);
+    }
+    void update_speed_manual(float delta)
+    {
+        float ts = *params[par_treblespeed];
+        float bs = *params[par_bassspeed];
+        incr_towards(maspeed_h, ts, delta * 200, delta * 200);
+        incr_towards(maspeed_l, bs, delta * 200, delta * 200);
+        dphase_h = rpm2dphase(maspeed_h);
+        dphase_l = rpm2dphase(maspeed_l);
     }
     /// map a ramp [int] to a sinusoid-like function [0, 65536]
     static inline int pseudo_sine_scl(int counter)
@@ -649,15 +679,16 @@ public:
         double v = counter * (1.0 / (65536.0 * 32768.0));
         return 32768 + 32768 * (v - v*v*v) * (1.0 / 0.3849);
     }
-    inline bool update_speed(float &aspeed, float delta_decc, float delta_acc)
+    /// Increase or decrease aspeed towards raspeed, with required negative and positive rate
+    inline bool incr_towards(float &aspeed, float raspeed, float delta_decc, float delta_acc)
     {
-        if (aspeed < dspeed) {
-            aspeed = min(dspeed, aspeed + delta_acc);
+        if (aspeed < raspeed) {
+            aspeed = min(raspeed, aspeed + delta_acc);
             return true;
         }
-        else if (aspeed > dspeed) 
+        else if (aspeed > raspeed) 
         {
-            aspeed = max(dspeed, aspeed - delta_decc);
+            aspeed = max(raspeed, aspeed - delta_decc);
             return true;
         }        
         return false;
@@ -702,10 +733,15 @@ public:
         crossover2l.sanitize_d2();
         crossover2r.sanitize_d2();
         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();
+        if (vibrato_mode == 5)
+            update_speed_manual(delta);
+        else
+        {
+            bool u1 = incr_towards(aspeed_l, dspeed, delta * 0.2, delta * 0.14);
+            bool u2 = incr_towards(aspeed_h, dspeed, delta, delta * 0.5);
+            if (u1 || u2)
+                set_vibrato();
+        }
         return outputs_mask;
     }
     virtual void control_change(int ctl, int val)
diff --git a/src/giface.cpp b/src/giface.cpp
index 2182b7d..373db7c 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -172,6 +172,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_RPM: return string(buf) + " rpm";
     case PF_UNIT_DEG: return string(buf) + " deg";
     case PF_UNIT_NOTE: 
         {
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index 56bc713..fc6ca13 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -106,7 +106,8 @@ static const char *units[] = {
     "ue:semitone12TET", // - ask SWH
     "ue:bpm",
     "ue:degree",
-    "ue:midiNote" // question to SWH: the extension says midiNode, but that must be a typo
+    "ue:midiNote", // question to SWH: the extension says midiNode, but that must be a typo
+    NULL // rotations per minute
 };
 
 static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, giface_plugin_info *gpi, int param)
@@ -149,7 +150,7 @@ static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, gifa
     ss << ind << "lv2:minimum " << pp.min << " ;\n";
     ss << ind << "lv2:maximum " << pp.max << " ;\n";
     uint8_t unit = (pp.flags & PF_UNITMASK) >> 24;
-    if (unit > 0 && unit < (sizeof(units) / sizeof(char *)))
+    if (unit > 0 && unit < (sizeof(units) / sizeof(char *)) && units[unit - 1] != NULL)
         ss << ind << "ue:unit " << units[unit - 1] << " ;\n";
     
     // for now I assume that the only tempo passed is the tempo the plugin should operate with
diff --git a/src/modules.cpp b/src/modules.cpp
index 7fd7e55..6486ebe 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -160,13 +160,15 @@ ALL_WRAPPERS(vintage_delay)
 
 const char *rotary_speaker_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R"};
 
-const char *rotary_speaker_speed_names[] = { "Off", "Chorale", "Tremolo", "HoldPedal", "ModWheel" };
+const char *rotary_speaker_speed_names[] = { "Off", "Chorale", "Tremolo", "HoldPedal", "ModWheel", "Manual" };
 
 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" },
+    { 2,         0,  5, 1.01, PF_ENUM | PF_CTL_COMBO, rotary_speaker_speed_names, "vib_speed", "Speed Mode" },
     { 0.5,        0,    1,    0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "spacing", "Tap Spacing" },
     { 0.5,        0,    1,    0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "shift", "Tap Offset" },
     { 0.15,       0,    1,    0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "mod_depth", "Mod Depth" },
+    { 390,       10,   600,    0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_LOG | PF_UNIT_RPM, NULL, "treble_speed", "Treble Motor" },
+    { 410,      10,   600,    0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_LOG | PF_UNIT_RPM, NULL, "bass_speed", "Bass Motor" },
 };
 
 static synth::ladspa_info rotary_speaker_info = { 0x8483, "RotarySpeaker", "Calf Rotary Speaker", "Krzysztof Foltman", copyright, "SimulationPlugin" };

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list