zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 324907a1bd9d2b22ecad21763bdf8c5327f56200
parent 5fbde4321f1874a570aa10f16c7eefaaa2c0a902
Author: Christopher A. Oliver <caowasteland@gmail.com>
Date:   Sun, 29 Nov 2015 23:57:12 -0500

Simple random non-alternating LFO

Diffstat:
Msrc/Params/LFOParams.h | 1+
Msrc/Synth/LFO.cpp | 11+++++++++--
Msrc/Synth/LFO.h | 6+++++-
Msrc/UI/LFOUI.fl | 4++++
4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/Params/LFOParams.h b/src/Params/LFOParams.h @@ -35,6 +35,7 @@ class XMLwrapper; #define LFO_RAMPDOWN 4 #define LFO_EXP_DOWN1 5 #define LFO_EXP_DOWN2 6 +#define LFO_RANDOM 7 class LFOParams:public Presets { diff --git a/src/Synth/LFO.cpp b/src/Synth/LFO.cpp @@ -29,7 +29,8 @@ #include <cmath> LFO::LFO(const LFOParams &lfopars, float basefreq, const AbsTime &t) - :delayTime(t, lfopars.Pdelay / 127.0f * 4.0f), //0..4 sec + :first_half(-1), + delayTime(t, lfopars.Pdelay / 127.0f * 4.0f), //0..4 sec waveShape(lfopars.PLFOtype), deterministic(!lfopars.Pfreqrand), dt_(t.dt()), @@ -88,7 +89,7 @@ LFO::LFO(const LFOParams &lfopars, float basefreq, const AbsTime &t) LFO::~LFO() {} -float LFO::baseOut(const char waveShape, const float phase) const +float LFO::baseOut(const char waveShape, const float phase) { switch(waveShape) { case LFO_TRIANGLE: @@ -109,6 +110,12 @@ float LFO::baseOut(const char waveShape, const float phase) const case LFO_RAMPDOWN: return (0.5f - phase) * 2.0f; case LFO_EXP_DOWN1: return powf(0.05f, phase) * 2.0f - 1.0f; case LFO_EXP_DOWN2: return powf(0.001f, phase) * 2.0f - 1.0f; + case LFO_RANDOM: + if ((phase < 0.5) != first_half) { + first_half = phase < 0.5; + last_random = 2*RND-1; + } + return last_random; default: return cosf(phase * 2.0f * PI); //LFO_SINE } } diff --git a/src/Synth/LFO.h b/src/Synth/LFO.h @@ -41,7 +41,7 @@ class LFO float lfoout(); float amplfoout(); private: - float baseOut(const char waveShape, const float phase) const; + float baseOut(const char waveShape, const float phase); //Phase of Oscillator float phase; //Phase Increment Per Frame @@ -51,6 +51,10 @@ class LFO //Amplitude Randomness float amp1, amp2; + // RND mode + int first_half; + float last_random; + //Intensity of the wave float lfointensity; //Amount Randomness diff --git a/src/UI/LFOUI.fl b/src/UI/LFOUI.fl @@ -131,6 +131,10 @@ hide();} {} label E2dn xywh {70 70 100 20} labelfont 1 labelsize 10 } + MenuItem {} { + label RND + xywh {80 80 100 20} labelfont 1 labelsize 10 + } } Fl_Check_Button continous { label {C.}