[SCM] calf/master: + Monosynth: Slower ramp on sound end, should eliminate some clicks on low cutoff sounds
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:36:52 UTC 2013
The following commit has been merged in the master branch:
commit 76dde77f4a3770c23c099057f29de34d027cf298
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Wed Jan 2 18:52:41 2008 +0000
+ Monosynth: Slower ramp on sound end, should eliminate some clicks on low cutoff sounds
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@66 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index 5d6e352..8c95372 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -59,7 +59,7 @@ public:
float freq, start_freq, target_freq, cutoff, decay_factor, fgain, fgain_delta, separation;
float detune, xpose, xfade, pitchbend, ampctl, fltctl, queue_vel;
float odcr, porta_time;
- int queue_note_on;
+ int queue_note_on, stop_count;
int legato;
synth::adsr envelope;
diff --git a/src/monosynth.cpp b/src/monosynth.cpp
index e03d692..3842f04 100644
--- a/src/monosynth.cpp
+++ b/src/monosynth.cpp
@@ -231,6 +231,7 @@ void monosynth_audio_module::activate() {
running = false;
output_pos = 0;
queue_note_on = -1;
+ stop_count = 0;
pitchbend = 1.f;
filter.reset();
filter2.reset();
@@ -277,7 +278,6 @@ void monosynth_audio_module::activate() {
}
waves[wave_skewsaw].make(bl, data);
for (int i = 0; i < 2048; i++) {
- int ii = (i < 1024) ? i : (2048 - i);
data[i] = (min(1.f, (float)(i / 64.f))) * (1.0 - i / 2048.0) * (fmod (i * i / 262144.0, 2.0) < 1.0 ? -1.0 : +1.0);
}
waves[wave_skewsqr].make(bl, data);
@@ -414,6 +414,7 @@ void monosynth_audio_module::calculate_buffer_stereo()
void monosynth_audio_module::delayed_note_on()
{
+ stop_count = 0;
porta_time = 0.f;
start_freq = freq;
target_freq = freq = 440 * pow(2.0, (queue_note_on - 69) / 12.0);
@@ -558,7 +559,18 @@ void monosynth_audio_module::calculate_step()
newfgain = ampctl;
break;
}
- newfgain *= 1.0 - (1.0 - env) * e2a;
+ float aenv = env;
+ /* isn't as good as expected
+ if (e2a > 1.0) { // extra-steep release on amplitude envelope only
+ if (envelope.state == adsr::RELEASE && env < envelope.sustain) {
+ aenv -= (envelope.sustain - env) * (e2a - 1.0);
+ if (aenv < 0.f) aenv = 0.f;
+ printf("aenv = %f\n", aenv);
+ }
+ e2a = 1.0;
+ }
+ */
+ newfgain *= 1.0 - (1.0 - aenv) * e2a;
fgain_delta = (newfgain - fgain) * (1.0 / step_size);
switch(filter_type)
{
@@ -579,11 +591,14 @@ void monosynth_audio_module::calculate_step()
}
if (envelope.state == adsr::STOP)
{
+ enum { ramp = step_size * 4 };
for (int i = 0; i < step_size; i++)
- buffer[i] *= (step_size - i) * (1.0f / step_size);
+ buffer[i] *= (ramp - i - stop_count) * (1.0f / ramp);
if (is_stereo_filter())
for (int i = 0; i < step_size; i++)
- buffer2[i] *= (step_size - i) * (1.0f / step_size);
- stopping = true;
+ buffer2[i] *= (ramp - i - stop_count) * (1.0f / ramp);
+ stop_count += step_size;
+ if (stop_count >= ramp)
+ stopping = true;
}
}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list