[SCM] calf/master: + Organ: removed old LFO, added allpass-based stereo vibrato instead
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:37:10 UTC 2013
The following commit has been merged in the master branch:
commit 24774383352f58c60ab18bd7e3e170fd7e3dbe6d
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Mon Apr 28 20:46:51 2008 +0000
+ Organ: removed old LFO, added allpass-based stereo vibrato instead
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@163 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index 5c2d9b8..75afe40 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -211,6 +211,7 @@ public:
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,
+ par_lforate, par_lfoamt, par_lfowet, par_lfophase,
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 62db8bc..e4857c1 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -57,6 +57,10 @@ struct organ_parameters {
organ_filter_parameters filters[organ_parameters::FilterCount];
organ_env_parameters envs[organ_parameters::EnvCount];
+ float lfo_rate;
+ float lfo_amt;
+ float lfo_wet;
+ float lfo_phase;
double perc_decay_const;
float multiplier[9];
@@ -78,6 +82,7 @@ public:
wave_sinepl1, wave_sinepl2, wave_sinepl3,
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_dsaw, wave_dsqr, wave_dpls,
wave_count };
enum {
ampctl_none,
@@ -104,7 +109,7 @@ public:
class organ_voice: public synth::voice, public organ_voice_base {
protected:
- enum { Channels = 2, BlockSize = 64, EnvCount = organ_parameters::EnvCount, FilterCount = organ_parameters::FilterCount };
+ enum { Channels = 2, BlockSize = 64, EnvCount = organ_parameters::EnvCount, FilterCount = organ_parameters::FilterCount, VibratoSize = 6 };
union {
float output_buffer[BlockSize][Channels];
float aux_buffers[3][BlockSize][Channels];
@@ -112,9 +117,11 @@ protected:
bool released;
dsp::fixed_point<int64_t, 52> phase, dphase;
biquad<float> filterL[2], filterR[2];
+ onepole<float> vibrato[2];
+ float vibrato_x1[VibratoSize][2], vibrato_y1[VibratoSize][2];
adsr envs[EnvCount];
inertia<linear_ramp> expression;
- float velocity;
+ float velocity, lfo_phase;
public:
organ_voice()
@@ -129,10 +136,13 @@ public:
filterL[i].reset();
filterR[i].reset();
}
+ for (int i = 0; i < VibratoSize; i++)
+ vibrato_x1[i][0] = vibrato_y1[i][0] = vibrato_x1[i][1] = vibrato_y1[i][1] = 0.f;
}
void note_on(int note, int vel) {
reset();
+ this->lfo_phase = 0.f;
this->note = note;
const float sf = 0.001f;
for (int i = 0; i < EnvCount; i++)
diff --git a/src/organ.cpp b/src/organ.cpp
index 2b6a426..2a415e3 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -100,8 +100,8 @@ const char *organ_audio_module::get_gui_xml()
DRAWBAR_UI("9")
"</table>"
"</vbox>"
- "<vbox page=\"Sound processor\">"
- "<hbox>"
+ "<hbox page=\"Sound processor\">"
+ "<vbox>"
"<frame label=\"Filter 1\">"
"<vbox>"
"<hbox>"
@@ -134,34 +134,6 @@ const char *organ_audio_module::get_gui_xml()
"</hbox>"
"</vbox>"
"</frame>"
- "<frame label=\"EG 1\">"
- "<vbox>"
- "<hbox>"
- "<vbox>"
- "<label param=\"adsr_a\" />"
- "<align><knob param=\"adsr_a\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_a\"/>"
- "</vbox>"
- "<vbox>"
- "<label param=\"adsr_d\" />"
- "<align><knob param=\"adsr_d\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_d\"/>"
- "</vbox>"
- "<vbox>"
- "<label param=\"adsr_s\" />"
- "<align><knob param=\"adsr_s\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_s\"/>"
- "</vbox>"
- "<vbox>"
- "<label param=\"adsr_r\" />"
- "<align><knob param=\"adsr_r\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_r\"/>"
- "</vbox>"
- "<vbox>"
- "<label param=\"adsr_v\" />"
- "<align><knob param=\"adsr_v\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_v\"/>"
- "</vbox>"
- "</hbox>"
- "</vbox>"
- "</frame>"
- "</hbox>"
- "<hbox>"
"<frame label=\"Filter 2\">"
"<vbox>"
"<hbox>"
@@ -194,6 +166,41 @@ const char *organ_audio_module::get_gui_xml()
"</hbox>"
"</vbox>"
"</frame>"
+ "<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>"
+ "</vbox>"
+ "<vbox>"
+ "<frame label=\"EG 1\">"
+ "<vbox>"
+ "<hbox>"
+ "<vbox>"
+ "<label param=\"adsr_a\" />"
+ "<align><knob param=\"adsr_a\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_a\"/>"
+ "</vbox>"
+ "<vbox>"
+ "<label param=\"adsr_d\" />"
+ "<align><knob param=\"adsr_d\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_d\"/>"
+ "</vbox>"
+ "<vbox>"
+ "<label param=\"adsr_s\" />"
+ "<align><knob param=\"adsr_s\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_s\"/>"
+ "</vbox>"
+ "<vbox>"
+ "<label param=\"adsr_r\" />"
+ "<align><knob param=\"adsr_r\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_r\"/>"
+ "</vbox>"
+ "<vbox>"
+ "<label param=\"adsr_v\" />"
+ "<align><knob param=\"adsr_v\" expand=\"0\" fill=\"0\"/></align><value param=\"adsr_v\"/>"
+ "</vbox>"
+ "</hbox>"
+ "</vbox>"
+ "</frame>"
"<frame label=\"EG 2\">"
"<vbox>"
"<hbox>"
@@ -220,15 +227,6 @@ const char *organ_audio_module::get_gui_xml()
"</hbox>"
"</vbox>"
"</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>"
@@ -255,8 +253,28 @@ const char *organ_audio_module::get_gui_xml()
"</hbox>"
"</vbox>"
"</frame>"
- "</hbox>"
- "</vbox>"
+ "</vbox>"
+ "<frame label=\"LFO\">"
+ "<vbox>"
+ "<vbox>"
+ "<label param=\"vib_rate\" />"
+ "<align><knob param=\"vib_rate\" expand=\"0\" fill=\"0\"/></align><value param=\"vib_rate\"/>"
+ "</vbox>"
+ "<vbox>"
+ "<label param=\"vib_amt\" />"
+ "<align><knob param=\"vib_amt\" expand=\"0\" fill=\"0\"/></align><value param=\"vib_amt\"/>"
+ "</vbox>"
+ "<vbox>"
+ "<label param=\"vib_wet\" />"
+ "<align><knob param=\"vib_wet\" expand=\"0\" fill=\"0\"/></align><value param=\"vib_wet\"/>"
+ "</vbox>"
+ "<vbox>"
+ "<label param=\"vib_phase\" />"
+ "<align><knob param=\"vib_phase\" expand=\"0\" fill=\"0\"/></align><value param=\"vib_phase\"/>"
+ "</vbox>"
+ "</vbox>"
+ "</frame>"
+ "</hbox>"
"</notebook>"
"</vbox>"
;
@@ -266,7 +284,16 @@ const char *organ_audio_module::port_names[] = {"Out L", "Out R"};
const char *organ_percussion_harmonic_names[] = { "2nd", "3rd" };
-const char *organ_wave_names[] = { "Sin", "S0", "S00", "S000", "SSaw", "SSqr", "SPls", "Saw", "Sqr", "Pls", "S(", "Sq(", "S+", "Clvg", "Bell", "Bell2", "W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8", "W9" };
+const char *organ_wave_names[] = {
+ "Sin",
+ "S0", "S00", "S000",
+ "SSaw", "SSqr", "SPls",
+ "Saw", "Sqr", "Pls",
+ "S(", "Sq(", "S+", "Clvg",
+ "Bell", "Bell2",
+ "W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8", "W9",
+ "DSaw", "DSqr", "DPls",
+};
const char *organ_routing_names[] = { "Out", "Flt 1", "Flt 2" };
@@ -388,6 +415,10 @@ parameter_properties organ_audio_module::param_props[] = {
{ 0, 0, organ_voice_base::ampctl_count - 1,
0, PF_INT | PF_CTL_COMBO, organ_ampctl_names, "eg3_amp_ctl", "EG3 To Amp"},
+ { 6.6, 0.01, 80, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "vib_rate", "Vib Rate" },
+ { 0.5, 0, 1, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB , NULL, "vib_amt", "Vib Mod Amt" },
+ { 0.5, 0, 1, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB , NULL, "vib_wet", "Vib Wet" },
+ { 180, 0, 360, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_DEG, NULL, "vib_phase", "Vib Stereo" },
// { 0, 0, organ_voice_base::ampctl_count - 1,
// 0, PF_INT | PF_CTL_COMBO, organ_ampctl_names, "vel_amp_ctl", "Vel To Amp"},
};
@@ -408,6 +439,19 @@ static void smoothen(bandlimiter<ORGAN_WAVE_BITS> &bl, float tmp[ORGAN_WAVE_SIZE
normalize_waveform(tmp, ORGAN_WAVE_SIZE);
}
+static void phaseshift(bandlimiter<ORGAN_WAVE_BITS> &bl, float tmp[ORGAN_WAVE_SIZE])
+{
+ bl.compute_spectrum(tmp);
+ for (int i = 1; i <= ORGAN_WAVE_SIZE / 2; i++) {
+ float phase = sin(i*i);
+ complex<float> shift = complex<float>(cos(phase), sin(phase));
+ bl.spectrum[i] *= shift;
+ bl.spectrum[ORGAN_WAVE_SIZE - i] *= conj(shift);
+ }
+ bl.compute_waveform(tmp);
+ normalize_waveform(tmp, ORGAN_WAVE_SIZE);
+}
+
organ_voice_base::organ_voice_base(organ_parameters *_parameters)
: parameters(_parameters)
@@ -550,6 +594,24 @@ organ_voice_base::organ_voice_base(organ_parameters *_parameters)
}
normalize_waveform(tmp, ORGAN_WAVE_SIZE);
waves[wave_w9].make(bl, tmp);
+
+ for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
+ tmp[i] = -1 + (i * 2.0 / ORGAN_WAVE_SIZE);
+ normalize_waveform(tmp, ORGAN_WAVE_SIZE);
+ phaseshift(bl, tmp);
+ waves[wave_dsaw].make(bl, tmp);
+
+ for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
+ tmp[i] = (i < (ORGAN_WAVE_SIZE / 2)) ? 1 : -1;
+ normalize_waveform(tmp, ORGAN_WAVE_SIZE);
+ phaseshift(bl, tmp);
+ waves[wave_dsqr].make(bl, tmp);
+
+ for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
+ tmp[i] = (i < (ORGAN_WAVE_SIZE / 16)) ? 1 : 0;
+ normalize_waveform(tmp, ORGAN_WAVE_SIZE);
+ phaseshift(bl, tmp);
+ waves[wave_dpls].make(bl, tmp);
}
}
@@ -564,6 +626,7 @@ void organ_voice::render_block() {
dsp::fixed_point<int, 20> tphase, tdphase;
unsigned int foldvalue = parameters->foldvalue;
+ int muln = 0;
for (int h = 0; h < 9; h++)
{
float amp = parameters->drawbars[h];
@@ -575,7 +638,7 @@ void organ_voice::render_block() {
if (waveid < 0 || waveid >= wave_count)
waveid = 0;
- unsigned int rate = (dphase * hm).get();
+ uint32_t rate = (dphase * hm).get();
unsigned int foldback = 0;
while (rate > foldvalue)
{
@@ -587,7 +650,7 @@ void organ_voice::render_block() {
if (!data)
continue;
tphase.set((uint32_t)((phase * hm).get()) + parameters->phaseshift[h]);
- tdphase.set((uint32_t)(dphase * hm).get());
+ tdphase.set((uint32_t)rate);
float ampl = amp * 0.5f * (1 - parameters->pan[h]);
float ampr = amp * 0.5f * (1 + parameters->pan[h]);
float (*out)[Channels] = aux_buffers[dsp::fastf2i_drm(parameters->routing[h])];
@@ -597,15 +660,20 @@ void organ_voice::render_block() {
out[i][1] += wv * ampr;
tphase += tdphase;
}
+ if (h == 3 || h == 6)
+ muln++;
}
expression.set_inertia(parameters->cutoff);
phase += dphase * BlockSize;
- float eval[EnvCount];
+ float escl[EnvCount], eval[EnvCount];
for (int i = 0; i < EnvCount; i++)
- eval[i] = envs[i].value * (1.f + parameters->envs[i].velscale * (velocity - 1.f));
+ escl[i] = (1.f + parameters->envs[i].velscale * (velocity - 1.f));
+
+ for (int i = 0; i < EnvCount; i++)
+ eval[i] = envs[i].value * escl[i];
for (int i = 0; i < FilterCount; i++)
{
- float mod = parameters->filters[i].envmod[0] * eval[0];
+ float mod = parameters->filters[i].envmod[0] * eval[0] ;
mod += parameters->filters[i].keyf * 100 * (note - 60);
for (int j = 1; j < EnvCount; j++)
{
@@ -625,14 +693,14 @@ void organ_voice::render_block() {
bool any_running = false;
for (int i = 0; i < EnvCount; i++)
{
- float pre = envs[i].value;
+ float pre = eval[i];
envs[i].advance();
int mode = fastf2i_drm(parameters->envs[i].ampctl);
if (!envs[i].stopped())
any_running = true;
if (mode == ampctl_none)
continue;
- float post = envs[i].value;
+ float post = envs[i].value * escl[i];
amp_pre[mode - 1] *= pre;
amp_post[mode - 1] *= post;
}
@@ -648,9 +716,39 @@ void organ_voice::render_block() {
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;
}
+
+ float lfo1 = lfo_phase < 0.5 ? 2 * lfo_phase : 2 - 2 * lfo_phase;
+ float lfo_phase2 = lfo_phase + parameters->lfo_phase * (1.0 / 360.0);
+ if (lfo_phase2 >= 1.0)
+ lfo_phase2 -= 1.0;
+ float lfo2 = lfo_phase2 < 0.5 ? 2 * lfo_phase2 : 2 - 2 * lfo_phase2;
+ lfo_phase += parameters->lfo_rate * BlockSize / sample_rate;
+ if (lfo_phase >= 1.0)
+ lfo_phase -= 1.0;
+ vibrato[0].set_ap(3000 + 7000 * parameters->lfo_amt * lfo1 * lfo1, sample_rate);
+ vibrato[1].set_ap(3000 + 7000 * parameters->lfo_amt * lfo2 * lfo2, sample_rate);
+
+ float vib_wet = parameters->lfo_wet;
+ for (int c = 0; c < 2; c++)
+ {
+ for (int i = 0; i < (int) BlockSize; i++)
+ {
+ float v = output_buffer[i][c];
+ float v0 = v;
+ for (int t = 0; t < VibratoSize; t++)
+ v = vibrato[c].process_ap(v, vibrato_x1[t][c], vibrato_y1[t][c]);
+
+ output_buffer[i][c] += (v - v0) * vib_wet;
+ }
+ for (int t = 0; t < VibratoSize; t++)
+ {
+ sanitize(vibrato_x1[t][c]);
+ sanitize(vibrato_y1[t][c]);
+ }
+ }
if (released)
{
- for (int i=0; i < (int) BlockSize; i++) {
+ for (int i = 0; i < (int) BlockSize; i++) {
output_buffer[i][0] *= amp.get();
output_buffer[i][1] *= amp.get();
amp.age_lin((1.0/44100.0)/0.03,0.0);
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list