[SCM] calf/master: + Organ: initial support for pitch wheel

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


The following commit has been merged in the master branch:
commit e577008656960f88042ac7294a2a8f715b311455
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sat Jun 21 23:29:37 2008 +0000

    + Organ: initial support for pitch wheel
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@210 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index bad61c8..baf791e 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -220,6 +220,10 @@ public:
             ((float *)&par_values)[i] = *params[i];
         update_params();
     }
+    inline void pitch_bend(int amt)
+    {
+        drawbar_organ::pitch_bend(amt);
+    }
     void activate() {
         setup(srate);
         panic_flag = false;
diff --git a/src/calf/organ.h b/src/calf/organ.h
index 6fc7f4e..1aa12b1 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -70,6 +70,9 @@ struct organ_parameters {
     int phaseshift[9];
     float cutoff;
     unsigned int foldvalue;
+    float pitch_bend;
+    
+    organ_parameters() : pitch_bend(1.0f) {}
 
     inline int get_percussion_timbre() { return dsp::fastf2i_drm(percussion_timbre); }
 };
@@ -208,7 +211,7 @@ public:
             envs[i].set(sf * p.attack, sf * p.decay, p.sustain, sf * p.release, sample_rate / BlockSize);
             envs[i].note_on();
         }
-        dphase.set(synth::midi_note_to_phase(note, 0, sample_rate));
+        update_pitch();
         velocity = vel * 1.0 / 127.0;
         amp.set(1.0f);
         released = false;
@@ -227,6 +230,7 @@ public:
     virtual bool get_active() {
         return (note != -1) && amp.get_active();
     }
+    void update_pitch();
 };
 
 /// Not a true voice, just something with similar-ish interface.
@@ -254,10 +258,15 @@ public:
             filter.reset_d1();
         }
         this->note = note;
+        amp.set(1.0f);
+        update_pitch();
+    }
+    
+    void update_pitch()
+    {
         int timbre = parameters->get_percussion_timbre();
         static const int harm_muls[8] = { 1, 2, 3, 4, 8, 1, 2, 4 };
-        dphase.set(synth::midi_note_to_phase(note, 0, sample_rate) * harm_muls[timbre]);
-        amp.set(1.0f);
+        dphase.set(synth::midi_note_to_phase(note, 0, sample_rate) * harm_muls[timbre] * parameters->pitch_bend);
     }
 
     // this doesn't really have a voice interface
@@ -388,6 +397,7 @@ struct drawbar_organ: public synth::basic_synth {
         }
         synth::basic_synth::control_change(controller, value);
     }
+    void pitch_bend(int amt);
     virtual bool check_percussion() { 
         switch(dsp::fastf2i_drm(parameters->percussion_trigger))
         {        
diff --git a/src/calf/synth.h b/src/calf/synth.h
index 2fbbcf5..ef3622d 100644
--- a/src/calf/synth.h
+++ b/src/calf/synth.h
@@ -202,6 +202,8 @@ public:
     virtual void percussion_note_on(int note, int vel) {}
     virtual void control_change(int ctl, int val);
     virtual void note_off(int note, int vel);
+    /// amt = -8192 to 8191
+    virtual void pitch_bend(int amt) {}
     virtual void on_pedal_release();
     virtual bool check_percussion() { return active_voices.empty(); }
     virtual ~basic_synth();
diff --git a/src/organ.cpp b/src/organ.cpp
index 6e36a40..1cdc4de 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -877,6 +877,11 @@ void organ_vibrato::process(organ_parameters *parameters, float (*data)[2], unsi
     }
 }
 
+void organ_voice::update_pitch()
+{
+    dphase.set(synth::midi_note_to_phase(note, 0, sample_rate) * parameters->pitch_bend);
+}
+
 void organ_voice::render_block() {
     if (note == -1)
         return;
@@ -1042,6 +1047,17 @@ void drawbar_organ::update_params()
     parameters->foldvalue = (int)(dphase);
 }
 
+void drawbar_organ::pitch_bend(int amt)
+{
+    parameters->pitch_bend = pow(2.0, amt * 2 / (12.0 * 8192));
+    for (list<voice *>::iterator i = active_voices.begin(); i != active_voices.end(); i++)
+    {
+        organ_voice *v = dynamic_cast<organ_voice *>(*i);
+        v->update_pitch();
+    }
+    percussion.update_pitch();
+}
+
 void organ_audio_module::execute(int cmd_no)
 {
     switch(cmd_no)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list