Fade In LFO - Best Technique

For general discussion related FlowStone
Post Reply
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Fade In LFO - Best Technique

Post by Tronic »

Which technique you use to implement a fade-in to a LFO?
The concept would be to have a single envelope with attack and control the amplitude-stream of the LFO,
but as you well know to implement an envelope is always linked to a stressful computing for CPU,
you know or use other techniques to do this?
Exo
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK
Contact:

Re: Fade In LFO - Best Technique

Post by Exo »

For a synth?
Something like this should be enough....

Code: Select all

streamin lfo;
streamin fadeInTime;
streamin sampleRate;
streamout fadeInLfo;
float increment;
float fadeIn;
stage(0)
{
   increment = fadeInTime / sampleRate ;
   fadeIn = 0; //reset for every new voice
}

fadeInLfo = fadeIn * lfo;

fadeIn = min(fadeIn + increment, 1);
   


That should work for you. I don't think there is a simpler way than that.
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Fade In LFO - Best Technique

Post by KG_is_back »

Or alternatively you may use exponential fade in (basically the same idea of implementation as Exo's but different envelope shape)

Code: Select all

streamin lfo;
streamin fadeCoeff; //this is number usually around 0.9 (always 0-1 range)
streamout out;

float cut=1;

out=lfo*(1-cut); //cut is 1 on start and decays to zero over time

cut= cut*fadeCoeff; //fade coeff controls how fast cud decays


fadeCoef has to be calculated too. Generally it is e^(-1/T) where T is release time in samples.

Note that Release time is not the time it takes for the decay to reach 0, but 0.3679 instead. (exponential curve never really reaches 0).
Exponential curves often sound more natural to human eat than linear.
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Fade In LFO - Best Technique

Post by Tronic »

Thx for this code hint.
Post Reply