From e55192919612af44f5898f2a30825499ea81a216 Mon Sep 17 00:00:00 2001 From: Krzysztof Foltman Date: Thu, 1 Jul 2010 23:02:19 +0100 Subject: [PATCH 1/2] Add windowing-based antialiasing to hard sync in Monosynth; update last stretch even if synth is idle. (cherry picked from commit d64a0487d88f6730ef90dd6d79b892ad4a114138) --- .../ladspa_effect/calf/src/calf/metadata.h | 2 +- plugins/ladspa_effect/calf/src/metadata.cpp | 3 +- plugins/ladspa_effect/calf/src/monosynth.cpp | 29 +++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/plugins/ladspa_effect/calf/src/calf/metadata.h b/plugins/ladspa_effect/calf/src/calf/metadata.h index 6e3f94cf2..de17490c3 100644 --- a/plugins/ladspa_effect/calf/src/calf/metadata.h +++ b/plugins/ladspa_effect/calf/src/calf/metadata.h @@ -109,7 +109,7 @@ struct monosynth_metadata: public plugin_metadata par_lforate, par_lfodelay, par_lfofilter, par_lfopitch, par_lfopw, par_mwhl_lfo, par_scaledetune, par_env2tocutoff, par_env2tores, par_env2toamp, par_env2attack, par_env2decay, par_env2sustain, par_env2fade, par_env2release, - par_stretch1, + par_stretch1, par_window1, par_lfo1trig, par_lfo2trig, par_lfo2rate, par_lfo2delay, param_count }; diff --git a/plugins/ladspa_effect/calf/src/metadata.cpp b/plugins/ladspa_effect/calf/src/metadata.cpp index ca44b234a..bf73f8b22 100644 --- a/plugins/ladspa_effect/calf/src/metadata.cpp +++ b/plugins/ladspa_effect/calf/src/metadata.cpp @@ -703,7 +703,8 @@ CALF_PORT_PROPS(monosynth) = { { 0, -10000,10000, 21, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_FADER | PF_UNIT_MSEC, NULL, "adsr2_f", "EG2 Fade" }, { 50, 10,20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_FADER | PF_UNIT_MSEC, NULL, "adsr2_r", "Release" }, - { 1, 1, 16, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "o1_stretch", "Osc1 Stretch" }, + { 1, 1, 16, 0, PF_FLOAT | PF_SCALE_LOG | PF_UNIT_COEF | PF_CTL_KNOB, NULL, "o1_stretch", "Osc1 Stretch" }, + { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "o1_window", "Osc1 Window" }, { 0, 0, 1, 0, PF_ENUM | PF_CTL_COMBO, monosynth_lfotrig_names, "lfo1_trig", "LFO1 Trigger Mode" }, { 0, 0, 1, 0, PF_ENUM | PF_CTL_COMBO, monosynth_lfotrig_names, "lfo2_trig", "LFO2 Trigger Mode" }, diff --git a/plugins/ladspa_effect/calf/src/monosynth.cpp b/plugins/ladspa_effect/calf/src/monosynth.cpp index 5120eab81..d5c77c16f 100644 --- a/plugins/ladspa_effect/calf/src/monosynth.cpp +++ b/plugins/ladspa_effect/calf/src/monosynth.cpp @@ -222,12 +222,24 @@ bool monosynth_audio_module::get_graph(int index, int subindex, float *data, int if (wave == wave_sqr) wave = wave_saw; float *waveform = waves[wave].original; + float rnd_start = 1 - *params[par_window1] * 0.5f; + float scl = rnd_start < 1.0 ? 1.f / (1 - rnd_start) : 0.f; for (int i = 0; i < points; i++) { int pos = i * S / points; + float r = 1; if (index == par_wave1) + { + float ph = i * 1.0 / points; + if (ph < 0.5f) + ph = 1.f - ph; + ph = (ph - rnd_start) * scl; + if (ph < 0) + ph = 0; + r = 1.0 - ph * ph; pos = int(pos * 1.0 * last_stretch1 / 65536.0 ) % S; - data[i] = (sign * waveform[pos] + waveform[(pos + shift) & (S - 1)]) / (sign == -1 ? 1 : 2); + } + data[i] = r * (sign * waveform[pos] + waveform[(pos + shift) & (S - 1)]) / (sign == -1 ? 1 : 2); } return true; } @@ -281,10 +293,20 @@ void monosynth_audio_module::calculate_buffer_oscs(float lfo1) float cur_xfade = last_xfade; float xfade_step = (new_xfade - cur_xfade) * (1.0 / step_size); + float rnd_start = 1 - *params[par_window1] * 0.5f; + float scl = rnd_start < 1.0 ? 1.f / (1 - rnd_start) : 0.f; + for (uint32_t i = 0; i < step_size; i++) { //buffer[i] = lerp(osc1.get_phaseshifted(shift1, mix1), osc2.get_phaseshifted(shift2, mix2), cur_xfade); - buffer[i] = lerp(osc1.get_phasedist(stretch1, shift1, mix1), osc2.get_phaseshifted(shift2, mix2), cur_xfade); + float o1phase = osc1.phase / (65536.0 * 65536.0); + if (o1phase < 0.5) + o1phase = 1 - o1phase; + o1phase = (o1phase - rnd_start) * scl; + if (o1phase < 0) + o1phase = 0; + float r = 1.0 - o1phase * o1phase; + buffer[i] = lerp(r * osc1.get_phasedist(stretch1, shift1, mix1), osc2.get_phaseshifted(shift2, mix2), cur_xfade); osc1.advance(); osc2.advance(); shift1 += shift_delta1; @@ -436,6 +458,9 @@ void monosynth_audio_module::calculate_step() envelope2.advance(); lfo1.get(); lfo2.get(); + float modsrc[modsrc_count] = { 1, velocity, inertia_pressure.get_last(), modwheel_value, envelope1.value, envelope2.value, 0.5+0.5*lfo1.last, 0.5+0.5*lfo2.last}; + calculate_modmatrix(moddest, moddest_count, modsrc); + last_stretch1 = (int32_t)(65536 * dsp::clip(*params[par_stretch1] + 0.01f * moddest[moddest_o1stretch], 1.f, 16.f)); return; } lfo1.set_freq(*params[par_lforate], crate); From 2eba055de0f940ae90e65004abccdf2baff1a8a2 Mon Sep 17 00:00:00 2001 From: Krzysztof Foltman Date: Sun, 11 Jul 2010 09:31:22 +0100 Subject: [PATCH 2/2] Fix incorrect plugin class (spotted by Luis Garrido). It's SimulatorPlugin, not SimulationPlugin. (cherry picked from commit d971297ebebd9faf6c2640fdbecdfc553cd8407e) --- plugins/ladspa_effect/calf/src/metadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ladspa_effect/calf/src/metadata.cpp b/plugins/ladspa_effect/calf/src/metadata.cpp index bf73f8b22..4bfc37793 100644 --- a/plugins/ladspa_effect/calf/src/metadata.cpp +++ b/plugins/ladspa_effect/calf/src/metadata.cpp @@ -185,7 +185,7 @@ CALF_PORT_PROPS(rotary_speaker) = { { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_h", "High rotor" }, }; -CALF_PLUGIN_INFO(rotary_speaker) = { 0x8483, "RotarySpeaker", "Calf Rotary Speaker", "Krzysztof Foltman", calf_plugins::calf_copyright_info, "SimulationPlugin" }; +CALF_PLUGIN_INFO(rotary_speaker) = { 0x8483, "RotarySpeaker", "Calf Rotary Speaker", "Krzysztof Foltman", calf_plugins::calf_copyright_info, "SimulatorPlugin" }; ////////////////////////////////////////////////////////////////////////////