[SCM] calf/master: + Monosynth: add a basic LFO
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:17 UTC 2013
The following commit has been merged in the master branch:
commit f26eb8e39ca649e6ae832bff12ae81082405ecbf
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Mon Feb 2 23:27:24 2009 +0000
+ Monosynth: add a basic LFO
diff --git a/gui/gui-monosynth.xml b/gui/gui-monosynth.xml
index 493f1d0..cf26686 100644
--- a/gui/gui-monosynth.xml
+++ b/gui/gui-monosynth.xml
@@ -72,6 +72,30 @@
</vbox>
</frame>
</hbox>
+ <frame label="LFO">
+ <hbox spacing="10">
+ <vbox>
+ <label param="lfo_rate"/>
+ <knob param="lfo_rate"/>
+ <value param="lfo_rate"/>
+ </vbox>
+ <vbox>
+ <label param="lfo_delay"/>
+ <knob param="lfo_delay"/>
+ <value param="lfo_delay"/>
+ </vbox>
+ <vbox>
+ <label param="lfo_filter"/>
+ <knob param="lfo_filter" type="1"/>
+ <value param="lfo_filter"/>
+ </vbox>
+ <vbox>
+ <label param="lfo_pitch"/>
+ <knob param="lfo_pitch"/>
+ <value param="lfo_pitch"/>
+ </vbox>
+ </hbox>
+ </frame>
<hbox spacing="10">
<frame label="Envelope">
<vbox border="10" spacing="10">
@@ -127,6 +151,7 @@
<vbox>
<label param="legato" expand="0"/>
<combo param="legato" expand="0" fill="0"/>
+ <label />
</vbox>
<vbox>
<label param="master"/>
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 16104ce..4b857bb 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -97,7 +97,10 @@ struct monosynth_metadata: public plugin_metadata<monosynth_metadata>
{
enum { wave_saw, wave_sqr, wave_pulse, wave_sine, wave_triangle, wave_varistep, wave_skewsaw, wave_skewsqr, wave_test1, wave_test2, wave_test3, wave_test4, wave_test5, wave_test6, wave_test7, wave_test8, wave_count };
enum { flt_lp12, flt_lp24, flt_2lp12, flt_hp12, flt_lpbr, flt_hpbr, flt_bp6, flt_2bp6 };
- enum { par_wave1, par_wave2, par_detune, par_osc2xpose, par_oscmode, par_oscmix, par_filtertype, par_cutoff, par_resonance, par_cutoffsep, par_envmod, par_envtores, par_envtoamp, par_attack, par_decay, par_sustain, par_release, par_keyfollow, par_legato, par_portamento, par_vel2filter, par_vel2amp, par_master, param_count };
+ enum { par_wave1, par_wave2, par_detune, par_osc2xpose, par_oscmode, par_oscmix, par_filtertype, par_cutoff, par_resonance, par_cutoffsep, par_envmod, par_envtores, par_envtoamp, par_attack, par_decay, par_sustain, par_release,
+ par_keyfollow, par_legato, par_portamento, par_vel2filter, par_vel2amp, par_master,
+ par_lforate, par_lfodelay, par_lfofilter, par_lfopitch,
+ param_count };
enum { in_count = 0, out_count = 2, support_midi = true, require_midi = true, rt_capable = true };
enum { step_size = 64 };
PLUGIN_NAME_ID_LABEL("monosynth", "monosynth", "Monosynth")
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index d55696b..5dd6692 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -46,6 +46,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;
bool running, stopping, gate, force_fadeout;
int last_key;
@@ -57,7 +58,7 @@ public:
int wave1, wave2, filter_type, last_filter_type;
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;
+ float odcr, porta_time, lfo_bend, lfo_clock;
int queue_note_on, stop_count;
int legato;
dsp::adsr envelope;
@@ -80,8 +81,8 @@ public:
/// Update oscillator frequency based on base frequency, detune amount, pitch bend scaling factor and sample rate.
inline void set_frequency()
{
- osc1.set_freq(freq * (2 - detune) * pitchbend, srate);
- osc2.set_freq(freq * (detune) * pitchbend * xpose, srate);
+ osc1.set_freq(freq * (2 - detune) * pitchbend * lfo_bend, srate);
+ osc2.set_freq(freq * (detune) * pitchbend * lfo_bend * xpose, srate);
}
/// Handle control change messages.
void control_change(int controller, int value);
diff --git a/src/calf/osc.h b/src/calf/osc.h
index 8a3a90e..dd1eb37 100644
--- a/src/calf/osc.h
+++ b/src/calf/osc.h
@@ -235,6 +235,25 @@ struct waveform_oscillator: public simple_oscillator
}
};
+/**
+ * Simple triangle LFO without any smoothing or anything of this sort.
+ */
+struct triangle_lfo: public simple_oscillator
+{
+ inline float get()
+ {
+ uint32_t phase2 = phase;
+ // start at 90 degrees point of the "/\" wave (-1 to +1)
+ phase2 += 1<<30;
+ // if in second half, invert the wave (so it falls back into 0..0x7FFFFFFF)
+ phase2 ^= ((int32_t)phase2)>>31;
+
+ float value = (phase2 >> 6) / 16777216.0 - 1.0;
+ phase += phasedelta;
+ return value;
+ }
+};
+
/// Simple stupid inline function to normalize a waveform (by removing DC offset and ensuring max absolute value of 1).
static inline void normalize_waveform(float *table, unsigned int size)
{
diff --git a/src/modules.cpp b/src/modules.cpp
index 430dde6..7d4f188 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -266,7 +266,7 @@ CALF_PORT_PROPS(monosynth) = {
{ 1, 0, 7, 0, PF_ENUM | PF_CTL_COMBO | PF_PROP_GRAPH, monosynth_filter_choices, "filter", "Filter" },
{ 33, 10,16000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "cutoff", "Cutoff" },
{ 2, 0.7, 8, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL, "res", "Resonance" },
- { 0, -2400, 2400, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "filter_sep", "Separation" },
+ { 0, -4800, 4800, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "filter_sep", "Separation" },
{ 8000, -10800,10800, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "env2cutoff", "Env->Cutoff" },
{ 1, 0, 1, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "env2res", "Env->Res" },
{ 1, 0, 1, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "env2amp", "Env->Amp" },
@@ -284,6 +284,11 @@ CALF_PORT_PROPS(monosynth) = {
{ 0, 0, 1, 0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "vel2amp", "Vel->Amp" },
{ 0.5, 0, 1, 100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_PROP_OUTPUT_GAIN, NULL, "master", "Volume" },
+
+ { 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, "lfo_filter", "LFO->Filter" },
+ { 0, 0, 1200, 0, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "lfo_pitch", "LFO->Pitch" },
};
////////////////////////////////////////////////////////////////////////////
diff --git a/src/monosynth.cpp b/src/monosynth.cpp
index a0feaf2..77a3ccc 100644
--- a/src/monosynth.cpp
+++ b/src/monosynth.cpp
@@ -40,6 +40,7 @@ void monosynth_audio_module::activate() {
queue_note_on = -1;
stop_count = 0;
pitchbend = 1.f;
+ lfo_bend = 1.0;
filter.reset();
filter2.reset();
stack.clear();
@@ -267,7 +268,8 @@ void monosynth_audio_module::delayed_note_on()
osc2.waveform = waves[wave2].get_level(osc2.phasedelta);
if (!osc1.waveform) osc1.waveform = silence;
if (!osc2.waveform) osc2.waveform = silence;
-
+ lfo_clock = 0.f;
+
if (!running)
{
if (legato >= 2)
@@ -276,6 +278,7 @@ void monosynth_audio_module::delayed_note_on()
osc2.reset();
filter.reset();
filter2.reset();
+ lfo.reset();
switch((int)*params[par_oscmode])
{
case 1:
@@ -335,6 +338,7 @@ void monosynth_audio_module::calculate_step()
envelope.advance();
return;
}
+ lfo.set_freq(*params[par_lforate], crate);
float porta_total_time = *params[par_portamento] * 0.001f;
if (porta_total_time >= 0.00101f && porta_time >= 0) {
@@ -349,10 +353,14 @@ void monosynth_audio_module::calculate_step()
porta_time += odcr;
}
}
+ float lfov = lfo.get() * std::min(1.0f, lfo_clock / *params[par_lfodelay]);
+ lfo_clock += odcr;
+ if (fabs(*params[par_lfopitch]) > small_value<float>())
+ lfo_bend = pow(2.0f, *params[par_lfopitch] * lfov * (1.f / 1200.0f));
set_frequency();
envelope.advance();
float env = envelope.value;
- cutoff = *params[par_cutoff] * pow(2.0f, env * fltctl * *params[par_envmod] * (1.f / 1200.f));
+ cutoff = *params[par_cutoff] * pow(2.0f, (lfov * *params[par_lfofilter] + env * fltctl * *params[par_envmod]) * (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);
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list