Initial jumps in speed when adjusting slider

Hi everyone!

I just started learning JUCE and decided to make a simple tremolo plugin.

The problem I’m having is that each time I touch the speed slider, the tremolo speed first jumps up by a ton before landing on the correct value.

Any help is very welcome!

You will want to calculate your period increment based on the LFO speed, instead of using a constant phase increment (1.0/sampleRate) like you are doing in the code currently. Might also be a good idea to use a double type for period/phase variable instead of the float you are using currently. (Or do some phase wrapping yourself if you want to keep on using the float for some reason.)

1 Like

Thanks for the reply!

I probably shouldn’t have called it period. it’s basically used as a Timer, so that if I have the speedparameter on 10:

2pi * time * 10, would create 10 cycles per second.

Alright, I did what you said and it fixed my problem haha.

period += juce::MathConstants::twoPi * smoothSpeedParam / getSampleRate();

    float lfo = sin(period);
    float lfoMapped = jmap(lfo, -1.f, 1.f, 0.f, 1.f);

I misunderstood how this for loop worked exactly.

Thanks for the help!