[SCM] calf/master: Implement second LFO and LFO retrig mode in Monosynth
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:40:14 UTC 2013
The following commit has been merged in the master branch:
commit c3f05c609d9597e9fa71f2c1fa1ec19f05e6a549
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Sun May 9 21:59:46 2010 +0100
Implement second LFO and LFO retrig mode in Monosynth
diff --git a/gui/gui-monosynth.xml b/gui/gui-monosynth.xml
index af0313a..3fea86f 100644
--- a/gui/gui-monosynth.xml
+++ b/gui/gui-monosynth.xml
@@ -156,6 +156,12 @@
</frame>
<frame label="LFO 1">
<vbox spacing="10">
+ <align>
+ <hbox>
+ <label param="lfo1_trig" text="Mode" />
+ <combo param="lfo1_trig" />
+ </hbox>
+ </align>
<hbox>
<vbox>
<label text="Rate"/>
@@ -194,22 +200,23 @@
</frame>
<frame label="LFO 2">
<vbox spacing="10">
+ <align>
+ <hbox>
+ <label param="lfo2_trig" text="Mode" />
+ <combo param="lfo2_trig" />
+ </hbox>
+ </align>
<hbox>
<vbox>
<label text="Rate"/>
- <knob param="lfo_rate"/>
- <value param="lfo_rate"/>
+ <knob param="lfo2_rate"/>
+ <value param="lfo2_rate"/>
</vbox>
<vbox>
<label text="Delay"/>
<knob param="lfo_delay"/>
<value param="lfo_delay"/>
</vbox>
- <vbox>
- <label text="ModWheel"/>
- <knob param="mwhl2lfo"/>
- <value param="mwhl2lfo"/>
- </vbox>
</hbox>
</vbox>
</frame>
@@ -257,7 +264,7 @@
</vbox>
<vbox>
<label text="To Amp"/>
- <toggle param="env2amp"/>
+ <toggle param="env2amp" size="1"/>
</vbox>
</vbox>
</hbox>
@@ -304,7 +311,7 @@
</vbox>
<vbox>
<label text="To Amp"/>
- <toggle param="adsr2_amp"/>
+ <toggle param="adsr2_amp" size="1"/>
</vbox>
</vbox>
</hbox>
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 4254b45..5cb0107 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -110,6 +110,8 @@ struct monosynth_metadata: public plugin_metadata<monosynth_metadata>
par_env2tocutoff, par_env2tores, par_env2toamp,
par_env2attack, par_env2decay, par_env2sustain, par_env2fade, par_env2release,
par_stretch1,
+ par_lfo1trig, par_lfo2trig,
+ par_lfo2rate, par_lfo2delay,
param_count };
enum { in_count = 0, out_count = 2, ins_optional = 0, outs_optional = 0, support_midi = true, require_midi = true, rt_capable = true };
enum { step_size = 64, step_shift = 6 };
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index 6f11e7f..3b7ca83 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -44,7 +44,7 @@ public:
uint32_t srate, crate;
static dsp::waveform_family<MONOSYNTH_WAVE_BITS> *waves;
dsp::waveform_oscillator<MONOSYNTH_WAVE_BITS> osc1, osc2;
- dsp::triangle_lfo lfo;
+ dsp::triangle_lfo lfo1, lfo2;
bool running, stopping, gate, force_fadeout;
int last_key;
@@ -64,7 +64,9 @@ public:
int filter_type, last_filter_type;
float freq, start_freq, target_freq, cutoff, fgain, fgain_delta, separation;
float detune, xpose, xfade, ampctl, fltctl, queue_vel;
- float odcr, porta_time, lfo_bend, lfo_clock, last_lfov, modwheel_value;
+ float odcr, porta_time, lfo_bend, lfo1_clock, lfo2_clock, modwheel_value;
+ /// Delay counter for LFOs
+ float lfo_clock;
/// Last value of phase shift for pulse width emulation for OSC1
int32_t last_pwshift1;
/// Last value of phase shift for pulse width emulation for OSC2
diff --git a/src/calf/osc.h b/src/calf/osc.h
index 85af5e6..779f1c0 100644
--- a/src/calf/osc.h
+++ b/src/calf/osc.h
@@ -19,8 +19,8 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef __CALF_OSC_H
-#define __CALF_OSC_H
+#ifndef CALF_OSC_H
+#define CALF_OSC_H
#include "fft.h"
#include <map>
@@ -284,6 +284,18 @@ struct waveform_oscillator: public simple_oscillator
*/
struct triangle_lfo: public simple_oscillator
{
+ /// Previous value (not stored here, but may be used by calling code)
+ float last;
+
+ triangle_lfo()
+ {
+ reset();
+ }
+ void reset()
+ {
+ simple_oscillator::reset();
+ last = 0;
+ }
inline float get()
{
uint32_t phase2 = phase;
diff --git a/src/calf/synth.h b/src/calf/synth.h
index 3495078..85fb354 100644
--- a/src/calf/synth.h
+++ b/src/calf/synth.h
@@ -19,8 +19,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1307, USA.
*/
-#ifndef __CALF_SYNTH_H
-#define __CALF_SYNTH_H
+#ifndef CALF_SYNTH_H
+#define CALF_SYNTH_H
#include <assert.h>
#include <math.h>
diff --git a/src/metadata.cpp b/src/metadata.cpp
index bd3cca3..f08fa48 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -602,6 +602,7 @@ const char *monosynth_waveform_names[] = { "Sawtooth", "Square", "Pulse", "Sine"
"Smooth Brass", "Bass", "Dark FM", "Multiwave", "Bell FM", "Dark Pad", "DCO Saw", "DCO Maze" };
const char *monosynth_mode_names[] = { "0\xC2\xB0 : 0\xC2\xB0", "0\xC2\xB0 : 180\xC2\xB0", "0\xC2\xB0 : 90\xC2\xB0", "90\xC2\xB0 : 90\xC2\xB0", "90\xC2\xB0 : 270\xC2\xB0", "Random" };
const char *monosynth_legato_names[] = { "Retrig", "Legato", "Fng Retrig", "Fng Legato" };
+const char *monosynth_lfotrig_names[] = { "Retrig", "Free" };
const char *monosynth_filter_choices[] = {
"12dB/oct Lowpass",
@@ -652,12 +653,12 @@ CALF_PORT_PROPS(monosynth) = {
{ 200, 0, 2400, 25, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "pbend_range", "PBend Range" },
- { 5, 0.01, 20, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "lfo_rate", "LFO Rate" },
- { 0.5, 0.1, 5, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "lfo_delay", "LFO Delay" },
- { 0, -4800, 4800, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "lfo2filter", "LFO->Filter" },
- { 100, 0, 1200, 0, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "lfo2pitch", "LFO->Pitch" },
- { 0, 0, 1, 0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "lfo2pw", "LFO->PW" },
- { 1, 0, 1, 0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "mwhl2lfo", "ModWheel->LFO" },
+ { 5, 0.01, 20, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "lfo_rate", "LFO1 Rate" },
+ { 0.5, 0, 5, 0, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "lfo_delay", "LFO1 Delay" },
+ { 0, -4800, 4800, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "lfo2filter", "LFO1->Filter" },
+ { 100, 0, 1200, 0, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "lfo2pitch", "LFO1->Pitch" },
+ { 0, 0, 1, 0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "lfo2pw", "LFO1->PW" },
+ { 1, 0, 1, 0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "mwhl2lfo", "ModWheel->LFO1" },
{ 1, 0, 1, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "scale_detune", "Scale Detune" },
@@ -672,6 +673,11 @@ CALF_PORT_PROPS(monosynth) = {
{ 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" },
+
+ { 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" },
+ { 5, 0.01, 20, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "lfo2_rate", "LFO1 Rate" },
+ { 0.5, 0.1, 5, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "lfo2_delay", "LFO1 Delay" },
};
////////////////////////////////////////////////////////////////////////////
diff --git a/src/monosynth.cpp b/src/monosynth.cpp
index 41011c5..ab085ae 100644
--- a/src/monosynth.cpp
+++ b/src/monosynth.cpp
@@ -255,7 +255,7 @@ bool monosynth_audio_module::get_graph(int index, int subindex, float *data, int
return get_static_graph(index, subindex, *params[index], data, points, context);
}
-void monosynth_audio_module::calculate_buffer_oscs(float lfo)
+void monosynth_audio_module::calculate_buffer_oscs(float lfo1)
{
int flag1 = (wave1 == wave_sqr);
int flag2 = (wave2 == wave_sqr);
@@ -263,13 +263,12 @@ void monosynth_audio_module::calculate_buffer_oscs(float lfo)
int32_t shift1 = last_pwshift1;
int32_t shift2 = last_pwshift2;
int32_t stretch1 = last_stretch1;
- int32_t shift_target1 = (int32_t)(0x78000000 * dsp::clip11(*params[par_pw1] + lfo * *params[par_lfopw] + 0.01f * moddest[moddest_o1pw]));
- int32_t shift_target2 = (int32_t)(0x78000000 * dsp::clip11(*params[par_pw2] + lfo * *params[par_lfopw] + 0.01f * moddest[moddest_o2pw]));
+ int32_t shift_target1 = (int32_t)(0x78000000 * dsp::clip11(*params[par_pw1] + lfo1 * *params[par_lfopw] + 0.01f * moddest[moddest_o1pw]));
+ int32_t shift_target2 = (int32_t)(0x78000000 * dsp::clip11(*params[par_pw2] + lfo1 * *params[par_lfopw] + 0.01f * moddest[moddest_o2pw]));
int32_t stretch_target1 = (int32_t)(65536 * dsp::clip(*params[par_stretch1] + 0.01f * moddest[moddest_o1stretch], 1.f, 16.f));
int32_t shift_delta1 = ((shift_target1 >> 1) - (last_pwshift1 >> 1)) >> (step_shift - 1);
int32_t shift_delta2 = ((shift_target2 >> 1) - (last_pwshift2 >> 1)) >> (step_shift - 1);
int32_t stretch_delta1 = ((stretch_target1 >> 1) - (last_stretch1 >> 1)) >> (step_shift - 1);
- last_lfov = lfo;
last_pwshift1 = shift_target1;
last_pwshift2 = shift_target2;
last_stretch1 = stretch_target1;
@@ -358,7 +357,6 @@ void monosynth_audio_module::delayed_note_on()
fltctl = 1.0 + (queue_vel - 1.0) * *params[par_vel2filter];
set_frequency();
lookup_waveforms();
- lfo_clock = 0.f;
if (!running)
{
@@ -369,7 +367,16 @@ void monosynth_audio_module::delayed_note_on()
osc2.reset();
filter.reset();
filter2.reset();
- lfo.reset();
+ if (*params[par_lfo1trig] <= 0)
+ {
+ lfo1.reset();
+ lfo1_clock = 0.f;
+ }
+ if (*params[par_lfo2trig] <= 0)
+ {
+ lfo2.reset();
+ lfo2_clock = 0.f;
+ }
switch((int)*params[par_oscmode])
{
case 1:
@@ -408,7 +415,7 @@ void monosynth_audio_module::delayed_note_on()
envelope1.advance();
envelope2.advance();
queue_note_on = -1;
- float modsrc[modsrc_count] = { 1, velocity, inertia_pressure.get_last(), modwheel_value, 0, 0.5+0.5*last_lfov};
+ float modsrc[modsrc_count] = { 1, velocity, inertia_pressure.get_last(), modwheel_value, 0, 0.5+0.5*lfo1.last, 0.5+0.5*lfo2.last};
calculate_modmatrix(moddest, moddest_count, modsrc);
}
@@ -437,7 +444,8 @@ void monosynth_audio_module::calculate_step()
envelope2.advance();
return;
}
- lfo.set_freq(*params[par_lforate], crate);
+ lfo1.set_freq(*params[par_lforate], crate);
+ lfo2.set_freq(*params[par_lfo2rate], crate);
float porta_total_time = *params[par_portamento] * 0.001f;
if (porta_total_time >= 0.00101f && porta_time >= 0) {
@@ -452,11 +460,12 @@ void monosynth_audio_module::calculate_step()
porta_time += odcr;
}
}
- float lfov = lfo.get() * std::min(1.0f, lfo_clock / *params[par_lfodelay]);
- lfov = lfov * dsp::lerp(1.f, modwheel_value, *params[par_mwhl_lfo]);
+ float lfov1 = lfo1.get() * std::min(1.0f, lfo_clock / *params[par_lfodelay]);
+ lfov1 = lfov1 * dsp::lerp(1.f, modwheel_value, *params[par_mwhl_lfo]);
+ float lfov2 = lfo2.get() * std::min(1.0f, lfo_clock / *params[par_lfo2delay]);
lfo_clock += odcr;
if (fabs(*params[par_lfopitch]) > small_value<float>())
- lfo_bend = pow(2.0f, *params[par_lfopitch] * lfov * (1.f / 1200.0f));
+ lfo_bend = pow(2.0f, *params[par_lfopitch] * lfov1 * (1.f / 1200.0f));
inertia_pitchbend.step();
set_frequency();
envelope1.advance();
@@ -466,11 +475,11 @@ void monosynth_audio_module::calculate_step()
// mod matrix
// this should be optimized heavily; I think I'll do it when MIDI in Ardour 3 gets stable :>
- float modsrc[modsrc_count] = { 1, velocity, inertia_pressure.get(), modwheel_value, env1, env2, 0.5+0.5*lfov, 0.5+0.5*lfov};
+ float modsrc[modsrc_count] = { 1, velocity, inertia_pressure.get(), modwheel_value, env1, env2, 0.5+0.5*lfov1, 0.5+0.5*lfov2};
calculate_modmatrix(moddest, moddest_count, modsrc);
inertia_cutoff.set_inertia(*params[par_cutoff]);
- cutoff = inertia_cutoff.get() * pow(2.0f, (lfov * *params[par_lfofilter] + env1 * fltctl * *params[par_env1tocutoff] + env2 * fltctl * *params[par_env2tocutoff] + moddest[moddest_cutoff]) * (1.f / 1200.f));
+ cutoff = inertia_cutoff.get() * pow(2.0f, (lfov1 * *params[par_lfofilter] + env1 * fltctl * *params[par_env1tocutoff] + env2 * fltctl * *params[par_env2tocutoff] + moddest[moddest_cutoff]) * (1.f / 1200.f));
if (*params[par_keyfollow] > 0.01f)
cutoff *= pow(freq / 264.f, *params[par_keyfollow]);
cutoff = dsp::clip(cutoff , 10.f, 18000.f);
@@ -539,7 +548,9 @@ void monosynth_audio_module::calculate_step()
if (moddest[moddest_attenuation] != 0.f)
newfgain *= dsp::clip<float>(1 - moddest[moddest_attenuation] * moddest[moddest_attenuation], 0.f, 1.f);
fgain_delta = (newfgain - fgain) * (1.0 / step_size);
- calculate_buffer_oscs(lfov);
+ calculate_buffer_oscs(lfov1);
+ lfo1.last = lfov1;
+ lfo2.last = lfov2;
switch(filter_type)
{
case flt_lp24:
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list