Question about lfo modulators
-
- KVRist
- 235 posts since 6 Sep, 2015
I did some naive lfos for a project but they sound terrible modulating cutoff and amplitude.
I had to low pass filter them to not sound like they were clicking like crazy at full mod amount
This was for saw tooth 1.0 to 0.0
Is this the correct approach?
I had to low pass filter them to not sound like they were clicking like crazy at full mod amount
This was for saw tooth 1.0 to 0.0
Is this the correct approach?
- KVRAF
- 9600 posts since 17 Sep, 2002 from Gothenburg Sweden
That sounds wrong to me but there's very little information to go on (audio clips, code,whatever).
Sounds like maybe you're only updating the LFO value once every proces call (ie. once every 32,64 or whatever samples) instead of updating ever sample.
Sounds like maybe you're only updating the LFO value once every proces call (ie. once every 32,64 or whatever samples) instead of updating ever sample.
-
- KVRist
- Topic Starter
- 235 posts since 6 Sep, 2015
Its typically when it reaches the reset point specially apparent on SAW type. I call it sample by sample.
Code: Select all
//problem here i think not sure if i should just change the phaser calculation instead
if(type==SAW){
double t = 1.0-phasor;
output = t;
}
Code: Select all
struct LFO
{
double phasor{0.0};
void reset() {
phasor=0.0;
}
enum LFOType
{
SAW=0,
RAMP,
TRI,
SIN,
};
double step(double freq,double srInv) {
double output = 0.0;
double dt = freq*srInv;
if(type==SAW){
double t = 1.0-phasor;
output = t;
}else if(type==RAMP) {
double t = phasor;
output = t;
}else if(type==TRI) {
output = 2*abs(phasor-floor(phasor+0.5));
}else{
output = (sin(2*phasor*std::numbers::pi_v<double>)+1.0)*0.5;
}
phasor += dt;
while(phasor >= 1.0) {
phasor-=1.0;
}
return output;
}
LFOType type;
};
- KVRist
- 362 posts since 1 Apr, 2009 from Hannover, Germany
It's expected for a discontinuity to produce clicks. For amplitude, you can smooth to reduce the clicks. For filter cutoff you should also look at the filter structure you're using and whether it deals gracefully with coefficient jumps. Classic biquads tend to explode upon large cutoff jumps, SVFs behave much better.
- KVRist
- 192 posts since 31 Oct, 2017
This is pretty normal. You can use a low pass filter, slew rate limiting etc.Marvinh wrote: Sun Mar 29, 2026 8:42 pm I had to low pass filter them to not sound like they were clicking like crazy at full mod amount
You're essentially generating a broadband click when you go directly from 0.0 to 1.0.
