[SCM] calf/master: Move large methods of Calf Organ-related classes into .cpp file.

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:01 UTC 2013


The following commit has been merged in the master branch:
commit efd55e0f3bd96499c25b1473067238b92a01dfff
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Mon Apr 5 13:41:51 2010 +0100

    Move large methods of Calf Organ-related classes into .cpp file.
    
    The marginal performance improvement is not worth ridiculously long compile
    times, especially on single-core machines. The trivial methods are still
    inline, but for larger methods the overhead of the method call is negligible
    and long compile times are putting too much burden on developers' patience.

diff --git a/src/calf/organ.h b/src/calf/organ.h
index 8a9b316..c95b397 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -175,14 +175,7 @@ public:
     void render_percussion_to(float (*buf)[2], int nsamples);
     void perc_note_on(int note, int vel);
     void perc_note_off(int note, int vel);
-    void perc_reset()
-    {
-        pphase = 0;
-        modphase = 0;
-        dpphase = 0;
-        moddphase = 0;
-        note = -1;
-    }
+    void perc_reset();
 };
 
 class organ_vibrato
@@ -224,57 +217,11 @@ public:
         inertia_pitchbend.set_now(1);
     }
 
-    void reset() {
-        inertia_pitchbend.ramp.set_length(sample_rate / (BlockSize * 30)); // 1/30s    
-        vibrato.reset();
-        phase = 0;
-        for (int i = 0; i < FilterCount; i++)
-        {
-            filterL[i].reset();
-            filterR[i].reset();
-        }
-    }
-
-    void note_on(int note, int vel) {
-        stolen = false;
-        finishing = false;
-        perc_released = false;
-        released = false;
-        reset();
-        this->note = note;
-        const float sf = 0.001f;
-        for (int i = 0; i < EnvCount; i++)
-        {
-            organ_parameters::organ_env_parameters &p = parameters->envs[i];
-            envs[i].set(sf * p.attack, sf * p.decay, p.sustain, sf * p.release, sample_rate / BlockSize);
-            envs[i].note_on();
-        }
-        update_pitch();
-        velocity = vel * 1.0 / 127.0;
-        amp.set(1.0f);
-        perc_note_on(note, vel);
-    }
-
-    void note_off(int /* vel */) {
-        // reset age to 0 (because decay will turn from exponential to linear, necessary because of error cumulation prevention)
-        perc_released = true;
-        if (pamp.get_active())
-        {
-            pamp.reinit();
-        }
-        rel_age_const = pamp.get() * ((1.0/44100.0)/0.03);
-        for (int i = 0; i < EnvCount; i++)
-            envs[i].note_off();
-    }
-
+    void reset();
+    void note_on(int note, int vel);
+    void note_off(int /* vel */);
     virtual float get_priority() { return stolen ? 20000 : (perc_released ? 1 : (sostenuto ? 200 : 100)); }
-    
-    virtual void steal() {
-        perc_released = true;
-        finishing = true;
-        stolen = true;
-    }
-
+    virtual void steal();
     void render_block();
     
     virtual int get_current_note() {
@@ -325,48 +272,17 @@ struct drawbar_organ: public dsp::basic_synth, public calf_plugins::organ_enums
     , percussion(_parameters) {
     }
     void render_separate(float *output[], int nsamples);
-    dsp::voice *alloc_voice() {
-        block_voice<organ_voice> *v = new block_voice<organ_voice>();
-        v->parameters = parameters;
-        return v;
-    }
-    virtual void percussion_note_on(int note, int vel) {
-        percussion.perc_note_on(note, vel);
-    }
+    dsp::voice *alloc_voice();
+    virtual void percussion_note_on(int note, int vel);
     virtual void params_changed() = 0;
-    virtual void setup(int sr) {
-        basic_synth::setup(sr);
-        percussion.setup(sr);
-        parameters->cutoff = 0;
-        params_changed();
-        global_vibrato.reset();
-    }
+    virtual void setup(int sr);
     void update_params();
     void control_change(int controller, int value)
     {
-#if 0
-        if (controller == 11)
-        {
-            parameters->cutoff = value / 64.0 - 1;
-        }
-#endif
         dsp::basic_synth::control_change(controller, value);
     }
     void pitch_bend(int amt);
-    virtual bool check_percussion() { 
-        switch(dsp::fastf2i_drm(parameters->percussion_trigger))
-        {        
-            case organ_voice_base::perctrig_first:
-                return active_voices.empty();
-            case organ_voice_base::perctrig_each: 
-            default:
-                return true;
-            case organ_voice_base::perctrig_eachplus:
-                return !percussion.get_noticable();
-            case organ_voice_base::perctrig_polyphonic:
-                return false;
-        }
-    }
+    virtual bool check_percussion();
 };
 
 };
diff --git a/src/organ.cpp b/src/organ.cpp
index 0d531c4..44e61b7 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -503,6 +503,17 @@ void organ_voice_base::render_percussion_to(float (*buf)[2], int nsamples)
     }
 }
 
+void organ_voice_base::perc_reset()
+{
+    pphase = 0;
+    modphase = 0;
+    dpphase = 0;
+    moddphase = 0;
+    note = -1;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void organ_vibrato::reset()
 {
     for (int i = 0; i < VibratoSize; i++)
@@ -550,6 +561,8 @@ void organ_vibrato::process(organ_parameters *parameters, float (*data)[2], unsi
     }
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void organ_voice::update_pitch()
 {
     organ_voice_base::update_pitch();
@@ -731,8 +744,64 @@ void organ_voice::render_block() {
     
     if (use_percussion())
         render_percussion_to(output_buffer, BlockSize);
+
+}
+
+void organ_voice::note_on(int note, int vel)
+{
+    stolen = false;
+    finishing = false;
+    perc_released = false;
+    released = false;
+    reset();
+    this->note = note;
+    const float sf = 0.001f;
+    for (int i = 0; i < EnvCount; i++)
+    {
+        organ_parameters::organ_env_parameters &p = parameters->envs[i];
+        envs[i].set(sf * p.attack, sf * p.decay, p.sustain, sf * p.release, sample_rate / BlockSize);
+        envs[i].note_on();
+    }
+    update_pitch();
+    velocity = vel * 1.0 / 127.0;
+    amp.set(1.0f);
+    perc_note_on(note, vel);
+}
+
+void organ_voice::note_off(int /* vel */)
+{
+    // reset age to 0 (because decay will turn from exponential to linear, necessary because of error cumulation prevention)
+    perc_released = true;
+    if (pamp.get_active())
+    {
+        pamp.reinit();
+    }
+    rel_age_const = pamp.get() * ((1.0/44100.0)/0.03);
+    for (int i = 0; i < EnvCount; i++)
+        envs[i].note_off();
+}
+
+void organ_voice::steal()
+{
+    perc_released = true;
+    finishing = true;
+    stolen = true;
 }
 
+void organ_voice::reset()
+{
+    inertia_pitchbend.ramp.set_length(sample_rate / (BlockSize * 30)); // 1/30s    
+    vibrato.reset();
+    phase = 0;
+    for (int i = 0; i < FilterCount; i++)
+    {
+        filterL[i].reset();
+        filterR[i].reset();
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
 void drawbar_organ::update_params()
 {
     parameters->perc_decay_const = dsp::decay::calc_exp_constant(1.0 / 1024.0, 0.001 * parameters->percussion_time * sample_rate);
@@ -746,6 +815,42 @@ void drawbar_organ::update_params()
     parameters->foldvalue = (int)(dphase);
 }
 
+dsp::voice *drawbar_organ::alloc_voice()
+{
+    block_voice<organ_voice> *v = new block_voice<organ_voice>();
+    v->parameters = parameters;
+    return v;
+}
+
+void drawbar_organ::percussion_note_on(int note, int vel)
+{
+    percussion.perc_note_on(note, vel);
+}
+
+void drawbar_organ::setup(int sr)
+{
+    basic_synth::setup(sr);
+    percussion.setup(sr);
+    parameters->cutoff = 0;
+    params_changed();
+    global_vibrato.reset();
+}
+
+bool drawbar_organ::check_percussion() { 
+    switch(dsp::fastf2i_drm(parameters->percussion_trigger))
+    {        
+        case organ_voice_base::perctrig_first:
+            return active_voices.empty();
+        case organ_voice_base::perctrig_each: 
+        default:
+            return true;
+        case organ_voice_base::perctrig_eachplus:
+            return !percussion.get_noticable();
+        case organ_voice_base::perctrig_polyphonic:
+            return false;
+    }
+}
+
 void drawbar_organ::pitch_bend(int amt)
 {
     parameters->pitch_bend = pow(2.0, (amt * parameters->pitch_bend_range) / (1200.0 * 8192.0));

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list