[SCM] calf/master: + Organ: envelope-based amplifier section

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


The following commit has been merged in the master branch:
commit ed6ad21a3abd537db0baf30d83b9ab6b8ed22f42
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sun Apr 13 08:59:20 2008 +0000

    + Organ: envelope-based amplifier section
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@159 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index 69377b3..5c2d9b8 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -208,9 +208,9 @@ public:
         par_percdecay, par_perclevel, par_percharm, par_master, 
         par_f1cutoff, par_f1res, par_f1env1, par_f1env2, par_f1env3, par_f1keyf,
         par_f2cutoff, par_f2res, par_f2env1, par_f2env2, par_f2env3, par_f2keyf,
-        par_eg1attack, par_eg1decay, par_eg1sustain, par_eg1release, par_eg1velscl,
-        par_eg2attack, par_eg2decay, par_eg2sustain, par_eg2release, par_eg2velscl,
-        par_eg3attack, par_eg3decay, par_eg3sustain, par_eg3release, par_eg3velscl,
+        par_eg1attack, par_eg1decay, par_eg1sustain, par_eg1release, par_eg1velscl, par_eg1ampctl, 
+        par_eg2attack, par_eg2decay, par_eg2sustain, par_eg2release, par_eg2velscl, par_eg2ampctl, 
+        par_eg3attack, par_eg3decay, par_eg3sustain, par_eg3release, par_eg3velscl, par_eg3ampctl, 
         param_count };
     enum { in_count = 0, out_count = 2, support_midi = true, rt_capable = true };
     static const char *port_names[];
diff --git a/src/calf/organ.h b/src/calf/organ.h
index 8fb4bb4..d8085b5 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -39,7 +39,7 @@ struct organ_parameters {
 
     struct organ_env_parameters
     {
-        float attack, decay, sustain, release, velscale;
+        float attack, decay, sustain, release, velscale, ampctl;
     };
         
     float drawbars[9];
@@ -79,6 +79,14 @@ public:
         wave_ssaw, wave_ssqr, wave_spls, wave_saw, wave_sqr, wave_pulse, wave_sinepl05, wave_sqr05, wave_halfsin, wave_clvg, wave_bell, wave_bell2,
         wave_w1, wave_w2, wave_w3, wave_w4, wave_w5, wave_w6, wave_w7, wave_w8, wave_w9,
         wave_count };
+    enum {
+        ampctl_none,
+        ampctl_direct,
+        ampctl_f1,
+        ampctl_f2,
+        ampctl_all,
+        ampctl_count
+    };
 protected:
     static waveform_family<ORGAN_WAVE_BITS> waves[wave_count];
     // dsp::sine_table<float, ORGAN_WAVE_SIZE, 1> sine_wave;
@@ -106,7 +114,7 @@ protected:
     biquad<float> filterL[2], filterR[2];
     adsr envs[EnvCount];
     inertia<linear_ramp> expression;
-    float velmod;
+    float velocity;
 
 public:
     organ_voice()
@@ -134,7 +142,7 @@ public:
             envs[i].note_on();
         }
         dphase.set(synth::midi_note_to_phase(note, 0, sample_rate));
-        velmod = vel * 1.0 / 127.0;
+        velocity = vel * 1.0 / 127.0;
         amp.set(1.0f);
         released = false;
     }
diff --git a/src/organ.cpp b/src/organ.cpp
index 2e85578..f90390c 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -222,6 +222,13 @@ const char *organ_audio_module::get_gui_xml()
                     "</frame>"
                 "</hbox>"
                 "<hbox>"
+                    "<frame label=\"Amplifier\">"
+                        "<vbox>"
+                            "<hbox><label param=\"eg1_amp_ctl\"/><combo param=\"eg1_amp_ctl\"/></hbox>"
+                            "<hbox><label param=\"eg2_amp_ctl\"/><combo param=\"eg2_amp_ctl\"/></hbox>"
+                            "<hbox><label param=\"eg3_amp_ctl\"/><combo param=\"eg3_amp_ctl\"/></hbox>"
+                        "</vbox>"
+                    "</frame>"
                     "<frame label=\"EG 3\">"
                         "<vbox>"
                             "<hbox>"
@@ -263,6 +270,8 @@ const char *organ_wave_names[] = { "Sin", "S0", "S00", "S000", "SSaw", "SSqr", "
 
 const char *organ_routing_names[] = { "Out", "Flt 1", "Flt 2"  };
 
+const char *organ_ampctl_names[] = { "None", "Direct", "Flt 1", "Flt 2", "All"  };
+
 parameter_properties organ_audio_module::param_props[] = {
     { 8,       0,  8, 80, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "l1", "16'" },
     { 8,       0,  8, 80, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "l2", "5 1/3'" },
@@ -360,18 +369,27 @@ parameter_properties organ_audio_module::param_props[] = {
     { 0.5,        0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr_s", "EG1 Sustain" },
     { 50,       10,20000,     0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_r", "EG1 Release" },
     { 0,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr_v", "EG1 VelMod" },
+    { 0,  0, organ_voice_base::ampctl_count - 1,
+                              0, PF_INT | PF_CTL_COMBO, organ_ampctl_names, "eg1_amp_ctl", "EG1 To Amp"},
 
     { 1,          1,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr2_a", "EG2 Attack" },
     { 350,       10,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr2_d", "EG2 Decay" },
     { 0.5,        0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr2_s", "EG2 Sustain" },
     { 50,       10,20000,     0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr2_r", "EG2 Release" },
     { 0,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr2_v", "EG2 VelMod" },
+    { 0,  0, organ_voice_base::ampctl_count - 1,
+                              0, PF_INT | PF_CTL_COMBO, organ_ampctl_names, "eg2_amp_ctl", "EG2 To Amp"},
 
     { 1,          1,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr3_a", "EG3 Attack" },
     { 350,       10,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr3_d", "EG3 Decay" },
     { 0.5,        0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr3_s", "EG3 Sustain" },
     { 50,       10,20000,     0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr3_r", "EG3 Release" },
     { 0,          0,    1,    0, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr3_v", "EG3 VelMod" },
+    { 0,  0, organ_voice_base::ampctl_count - 1,
+                              0, PF_INT | PF_CTL_COMBO, organ_ampctl_names, "eg3_amp_ctl", "EG3 To Amp"},
+
+//    { 0,  0, organ_voice_base::ampctl_count - 1,
+//                              0, PF_INT | PF_CTL_COMBO, organ_ampctl_names, "vel_amp_ctl", "Vel To Amp"},
 };
 
 ////////////////////////////////////////////////////////////////////////////
@@ -584,7 +602,7 @@ void organ_voice::render_block() {
     phase += dphase * BlockSize;
     float eval[EnvCount];
     for (int i = 0; i < EnvCount; i++)
-        eval[i] = envs[i].value * (1 + parameters->envs[i].velscale * (velmod - 1));
+        eval[i] = envs[i].value * (1.f + parameters->envs[i].velscale * (velocity - 1.f));
     for (int i = 0; i < FilterCount; i++)
     {
         float mod = parameters->filters[i].envmod[0] * eval[0];
@@ -598,11 +616,32 @@ void organ_voice::render_block() {
         filterL[i].set_lp_rbj(dsp::clip<float>(fc, 10, 18000), parameters->filters[i].resonance, sample_rate);
         filterR[i].copy_coeffs(filterL[i]);
     }
+    float amp_pre[ampctl_count - 1], amp_post[ampctl_count - 1];
+    for (int i = 0; i < ampctl_count; i++)
+    {
+        amp_pre[i] = 1.f;
+        amp_post[i] = 1.f;
+    }
     for (int i = 0; i < EnvCount; i++)
+    {
+        float pre = envs[i].value;
         envs[i].advance();
+        int mode = fastf2i_drm(parameters->envs[i].ampctl);
+        if (mode == ampctl_none)
+            continue;
+        float post = envs[i].value;
+        amp_pre[mode - 1] *= pre;
+        amp_post[mode - 1] *= post;
+    }
+    // calculate delta from pre and post
+    for (int i = 0; i < ampctl_count; i++)
+        amp_post[i] = (amp_post[i] - amp_pre[i]) * (1.0 / BlockSize);
+    float a0 = amp_pre[0], a1 = amp_pre[1], a2 = amp_pre[2], a3 = amp_pre[3];
+    float d0 = amp_post[0], d1 = amp_post[1], d2 = amp_post[2], d3 = amp_post[3];
     for (int i=0; i < (int) BlockSize; i++) {
-        output_buffer[i][0] += filterL[0].process_d1(aux_buffers[1][i][0]) + filterL[1].process_d1(aux_buffers[2][i][0]);
-        output_buffer[i][1] += filterR[0].process_d1(aux_buffers[1][i][1]) + filterR[1].process_d1(aux_buffers[2][i][1]);
+        output_buffer[i][0] = a3 * (a0 * output_buffer[i][0] + a1 * filterL[0].process_d1(aux_buffers[1][i][0]) + a2 * filterL[1].process_d1(aux_buffers[2][i][0]));
+        output_buffer[i][1] = a3 * (a0 * output_buffer[i][1] + a1 * filterR[0].process_d1(aux_buffers[1][i][1]) + a2 * filterR[1].process_d1(aux_buffers[2][i][1]));
+        a0 += d0, a1 += d1, a2 += d2, a3 += d3;
     }
     if (released)
     {

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list