Cabbage Logo
Back to Cabbage Site

Using an envelope to set LFO shape

I am wondering how I would go about using an envelope to determine the waveform of a lfo.
Something like the below code?

   kIntensity = 0.5
   kRate = 50
   kLFOEnv madsr .1, .2, .7, .4

   kLfo lfo kIntensity, kRate, kLFOEnv

You can’t do it like this. You’ll need to create a function table and read it with an oscillator, for example:

kIntensity = 0.5
kRate = 50
iLFOEnv = 10;function table ten

kLfo oscili kIntensity, kRate, iLFOEnv
1 Like

Ahh that’s perfect thanks a million :slight_smile:

Ok so I am still a bit stuck here, I usually try to simplify my questions but I probably left out the most important part there. My main goal was to get an envelope from slider values and pass it to the LFO. I am trying to do it using a function table but am unsure where to get the sustain time from.

iLFOEnv = 1

// table 1, use gen routine 7 for straight lines
f 1 0 1024 7

the next parameters in the function table are

0 chnget(“ENV_Attack”) p5
//Go from 0 to p5 in attack time

chnget(“ENV_Decay”) chnget(“ENV_Sustain”)
//Go to Sustain value in Decay Time

This is where I am unsure what too put in

chnget(“ENV_Release”) 0
//Go to 0 in release time

I think you’re slightly confusing the two. An ADSR won’t really work as an LFO waveform because it has an indeterminate sustain length. If you wish to create a custom waveform with sliders you could probably use ftgen and then use slider values to create different waveform shapes, and use them with oscil? Note that ftgen is i-time only. Check out how I do it with the Examples->Misc->SimpleTable. Maybe something like that might be interesting?