[SCM] calf/master: + JACK host: remove deadlock on shutdown + Organ: make polyphonic percussion click-free (more or less) at cost of code ugliness, simplify monophonic percussion phase reset code + Organ: make default percussion parameters more H****nd-like again (which means FM is not used by default, it still wastes CPU cycles though)

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


The following commit has been merged in the master branch:
commit 081823b9423ff814e9efa060cb4c1853270bb9b5
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Tue Aug 5 21:26:43 2008 +0000

    + JACK host: remove deadlock on shutdown
    + Organ: make polyphonic percussion click-free (more or less) at cost of code ugliness, simplify monophonic percussion phase reset code
    + Organ: make default percussion parameters more H****nd-like again (which means FM is not used by default, it still wastes CPU cycles though)
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@256 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/organ.h b/src/calf/organ.h
index 4b6696b..c76ffdb 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -170,8 +170,11 @@ protected:
     dsp::fixed_point<int64_t, 20> modphase, moddphase;
     float fm_keytrack;
     int &sample_rate_ref;
+    bool &released_ref;
+    /// pamp per-sample (linear) step during release stage (calculated on release so that it will take 30ms for it to go from "current value at release point" to 0)
+    float rel_age_const;
 
-    organ_voice_base(organ_parameters *_parameters, int &_sample_rate_ref);
+    organ_voice_base(organ_parameters *_parameters, int &_sample_rate_ref, bool &_released_ref);
     
     inline float wave(float *data, dsp::fixed_point<int, 20> ph) {
         return ph.lerp_table_lookup_float(data);
@@ -197,6 +200,7 @@ public:
     // this doesn't really have a voice interface
     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;
@@ -226,7 +230,6 @@ protected:
         float output_buffer[BlockSize][Channels];
         float aux_buffers[3][BlockSize][Channels];
     };
-    bool released;
     dsp::fixed_point<int64_t, 52> phase, dphase;
     biquad<float> filterL[2], filterR[2];
     adsr envs[EnvCount];
@@ -236,7 +239,7 @@ protected:
 
 public:
     organ_voice()
-    : organ_voice_base(NULL, sample_rate),
+    : organ_voice_base(NULL, sample_rate, released),
     expression(linear_ramp(16)) {
     }
 
@@ -268,6 +271,10 @@ public:
     }
 
     void note_off(int /* vel */) {
+        // reset age to 0 (because decay will turn from exponential to linear, necessary because of error cumulation prevention)
+        released = true;
+        pamp.reinit();
+        rel_age_const = pamp.get() * ((1.0/44100.0)/0.03);
         for (int i = 0; i < EnvCount; i++)
             envs[i].note_off();
     }
@@ -291,9 +298,11 @@ public:
 class percussion_voice: public organ_voice_base {
 public:
     int sample_rate;
+    bool released;
 
     percussion_voice(organ_parameters *_parameters)
-    : organ_voice_base(_parameters, sample_rate)
+    : organ_voice_base(_parameters, sample_rate, released)
+    , released(false)
     {
     }
     
diff --git a/src/calf/primitives.h b/src/calf/primitives.h
index 4e9823f..4085778 100644
--- a/src/calf/primitives.h
+++ b/src/calf/primitives.h
@@ -284,6 +284,12 @@ public:
         active = true;
         age = 0;
     }
+    /// reinitialise envelope (must be called if shape changes from linear to exponential or vice versa in the middle of envelope)
+    inline void reinit()
+    {
+        initial = value;
+        age = 1;
+    }
     inline void add(double v) {
         if (active)
             value += v;
@@ -302,7 +308,7 @@ public:
     inline void age_exp(double constant, double epsilon) {
         if (active) {
             if (!(age & mask))
-                value = initial * pow(constant, (double)(age + 1));
+                value = initial * pow(constant, (double)age);
             else
                 value *= constant;
             if (value < epsilon)
@@ -313,7 +319,7 @@ public:
     inline void age_lin(double constant, double epsilon) {
         if (active) {
             if (!(age & mask))
-                value = initial - constant * (age + 1);
+                value = initial - constant * age;
             else
                 value -= constant;
             if (value < epsilon)
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index 7e60862..63f958e 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -340,8 +340,8 @@ void host_session::close()
         g_source_remove(lash_source_id);
     main_win->on_closed();
     main_win->close_guis();
-    client.delete_plugins();
     client.deactivate();
+    client.delete_plugins();
     client.close();
 }
 
diff --git a/src/organ.cpp b/src/organ.cpp
index b36465f..c6d52e5 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -512,18 +512,18 @@ parameter_properties organ_audio_module::param_props[] = {
     
     { 200,         10,  3000, 100, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "perc_decay", "P: Carrier Decay" },
     { 0.25,      0,  1, 100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL, "perc_level", "P: Level" },
-    { 2,         0,  organ_voice_base::wave_count_small - 1, 1, PF_ENUM | PF_CTL_COMBO, organ_wave_names, "perc_waveform", "P: Carrier Wave" },
-    { 2,      1, 32, 32, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB, NULL, "perc_harmonic", "P: Carrier Frq" },
+    { 0,         0,  organ_voice_base::wave_count_small - 1, 1, PF_ENUM | PF_CTL_COMBO, organ_wave_names, "perc_waveform", "P: Carrier Wave" },
+    { 6,      1, 32, 32, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB, NULL, "perc_harmonic", "P: Carrier Frq" },
     { 0,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "perc_vel2amp", "P: Vel->Amp" },
     
     { 200,         10,  3000, 100, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "perc_fm_decay", "P: Modulator Decay" },
-    { 1,          0,    4,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "perc_fm_depth", "P: FM Depth" },
-    { 2,         0,  organ_voice_base::wave_count_small - 1, 1, PF_ENUM | PF_CTL_COMBO, organ_wave_names, "perc_fm_waveform", "P: Modulator Wave" },
-    { 2,      1, 32, 32, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB, NULL, "perc_fm_harmonic", "P: Modulator Frq" },
+    { 0,          0,    4,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "perc_fm_depth", "P: FM Depth" },
+    { 0,         0,  organ_voice_base::wave_count_small - 1, 1, PF_ENUM | PF_CTL_COMBO, organ_wave_names, "perc_fm_waveform", "P: Modulator Wave" },
+    { 6,      1, 32, 32, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB, NULL, "perc_fm_harmonic", "P: Modulator Frq" },
     { 0,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "perc_vel2fm", "P: Vel->FM" },
     
     { 0,         0,  organ_voice_base::perctrig_count - 1, 0, PF_ENUM | PF_CTL_COMBO, organ_percussion_trigger_names, "perc_trigger", "P: Trigger" },
-    { 0,       0,360, 361, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_DEG, NULL, "perc_stereo", "P: Stereo Phase" },
+    { 90,      0,360, 361, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_DEG, NULL, "perc_stereo", "P: Stereo Phase" },
 
     { 0,         0,  1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "filter_chain", "Filter 1 To 2" },
     { 0.1,         0,  1, 100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_PROP_OUTPUT_GAIN, NULL, "master", "Volume" },
@@ -927,9 +927,10 @@ void organ_voice_base::precalculate_waves()
     }
 }
 
-organ_voice_base::organ_voice_base(organ_parameters *_parameters, int &_sample_rate_ref)
+organ_voice_base::organ_voice_base(organ_parameters *_parameters, int &_sample_rate_ref, bool &_released_ref)
 : parameters(_parameters)
 , sample_rate_ref(_sample_rate_ref)
+, released_ref(_released_ref)
 {
     note = -1;
 }
@@ -968,11 +969,14 @@ void organ_voice_base::render_percussion_to(float (*buf)[2], int nsamples)
         fm *= ORGAN_WAVE_SIZE * parameters->percussion_fm_depth * fm_amp.get();
         modphase += moddphase;
         fm_amp.age_exp(fm_age_const, 1.0 / 32768.0);
-        
+
         float lamp = level * pamp.get();
         buf[i][0] += lamp * wave(data, pphase + dsp::fixed_point<int64_t, 52>(fm - s));
         buf[i][1] += lamp * wave(data, pphase + dsp::fixed_point<int64_t, 52>(fm + s));
-        pamp.age_exp(age_const, 1.0 / 32768.0);
+        if (released_ref)
+            pamp.age_lin(rel_age_const,0.0);
+        else
+            pamp.age_exp(age_const, 1.0 / 32768.0);
         pphase += dpphase;
     }
 }
@@ -1220,11 +1224,8 @@ void organ_audio_module::execute(int cmd_no)
 
 void organ_voice_base::perc_note_on(int note, int vel)
 {
-    // do not reset phase if voice is still running (to prevent clicks, even at cost of slight loss of "percussiveness")
-    if (!pamp.get_active())
-    {
-        perc_reset();
-    }
+    perc_reset();
+    released_ref = false;
     this->note = note;
     pamp.set(1.0f + (vel - 127) * parameters->percussion_vel2amp / 127.0);
     update_pitch();

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list