Question about lfo modulators

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

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?

Post

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.

Post

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;
    };

Post

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.

Post

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
This is pretty normal. You can use a low pass filter, slew rate limiting etc.

You're essentially generating a broadband click when you go directly from 0.0 to 1.0.

Post Reply

Return to “DSP and Plugin Development”