Creating an LFO to modulate filter frequency | Algorithm Design | Forum

guest

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

Creating an LFO to modulate filter frequency
New Member
Members
May 2, 2019 - 6:52 am
Member Since: May 2, 2019
Forum Posts: 1
Offline

Hi Will/all,

Â

I am currently designing a filter plugin for Ableton Live based on the RBJ cookbook, and am trying to wrap my head around how to implement an LFO to automate the filter frequency.

Â

Here's my thought process so far:

Â

- I have two variables, LFO rate (ranging from 0.02Hz to 20Hz) and LFO depth (ranging from 0 to 1). These will determine the frequency and amplitude of the LFO sine wave [Asin(2*pi*f*t)]

Â

- A = LFO depth, f = LFO rate and t will be a position in time that will determine the value that the LFO function will output

Â

- The value outputted by the LFO function will be multiplied by frequency, producing different frequency values over a certain range (LFO depth) at a certain speed (LFO rate)

Â

- I believe I need to take the *absolute* value of the LFO signal's output, as multiplying a negative output by frequency will produce a negative frequency, which doesn't make any sense.

Â

- I also have a 'switch' control to turn the LFO on or off. This outputs a 0 or a 1.

Â

I initially thought wrapping this LFO function in a for loop would be the way to go, but I actually need the LFO to run indefinitely, so I think a while loop (while LFO = on) makes sense.

Â

However, I still need a value for 't' in my sine wave equation, and I can't figure out how to determine this. In a real, voltage-controlled LFO, t would be a continuous function rather than discrete values.

My thought is that I can include a for loop within the while loop like so:

while (m_f_LFOOnOff = 1) {

for (float i = 0; i < ??; ++i) {

yt = abs(m_f_LFODepth * sin(2 * PI * m_f_LFORate * i));

return yt;
Â Â  }
}

But I'm not sure what my upper range for i would be. I'm not even sure that this would cause the LFO values to be outputted indefinitely, or whether it would simply run once.

Â

Member
Members
May 2, 2019 - 10:33 am
Member Since: July 11, 2017
Forum Posts: 18
Offline

You could just use a simple Oscillator. If you don't have Wills books you could look at the Maximillian libraries .https://github.com/micknoise/Maximilian

Â

They have some very basic OSC you could use as a LFO.Â

May 2, 2019 - 2:23 pm
Member Since: April 3, 2014
Forum Posts: 75
Offline

Hi Tom 🙂

Tom_1 said
Hi Will/all,

Â

I am currently designing a filter plugin for Ableton Live based on the RBJ cookbook, and am trying to wrap my head around how to implement an LFO to automate the filter frequency.

Â

Here's my thought process so far:

Â

- I have two variables, LFO rate (ranging from 0.02Hz to 20Hz) and LFO depth (ranging from 0 to 1). These will determine the frequency and amplitude of the LFO sine wave [Asin(2*pi*f*t)]

Â

- A = LFO depth, f = LFO rate and t will be a position in time that will determine the value that the LFO function will output

Â

- The value outputted by the LFO function will be multiplied by frequency, producing different frequency values over a certain range (LFO depth) at a certain speed (LFO rate)

I think here is your misconception: you probably don't want to multiply the "frequency" directly but an offset to that frequency. The "Frequency" of the LFO is not related to the "Frequency" of the filter you want it to modulate.Â

Â

- I believe I need to take the *absolute* value of the LFO signal's output, as multiplying a negative output by frequency will produce a negative frequency, which doesn't make any sense.
Â

- I also have a 'switch' control to turn the LFO on or off. This outputs a 0 or a 1.

Â

I initially thought wrapping this LFO function in a for loop would be the way to go, but I actually need the LFO to run indefinitely, so I think a while loop (while LFO = on) makes sense.

No, at least not for a single sample. For a single sample you will also most probably only have one value from the LFO. You "drive" the LFO only one sample at a time.

Â

However, I still need a value for 't' in my sine wave equation, and I can't figure out how to determine this. In a real, voltage-controlled LFO, t would be a continuous function rather than discrete values.

The t depends on the samplerate. For 44100 Hz one sample is basically 1/44100 which is roughly 0.023 milliseconds.

My thought is that I can include a for loop within the while loop like so:

while (m_f_LFOOnOff = 1) {

for (float i = 0; i &lt; ??; ++i) {

yt = abs(m_f_LFODepth * sin(2 * PI * m_f_LFORate * i));

return yt;

Â Â  }

}

This code snippet will always return 0. Most modern compilers will also issue a warning or even an error for the non-conditional return statement inside the for loop.

But I'm not sure what my upper range for i would be. I'm not even sure that this would cause the LFO values to be outputted indefinitely, or whether it would simply run once.

Â

Buy the book 😉 Maybe you can get your hands on a cheaper or second-hand "first edition" book when the second edition is out (which at least in germany is announced for the end of may).

Â

Cheers,

Tom

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
4 Guest(s)

1 Guest(s)

Top Posters:

Chaes: 56

Skyler: 48

StevieD: 46

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

Nickolai: 43

clau_ste: 39

jeanlecode: 37

Member Stats:

Guest Posters: 1

Members: 775

Moderators: 1