DSPFilters LFO Cutoff modulation

Sorry for the dumb question but I can't figure this out. I'm using DSPFilters implementing a RBJ low pass. I also have a simple LFO that I want to use to modulate the cutoff of the filter. Nothing happen if do something like this:

 for(int i = 0; i < numSamples; ++i )
 {
     params[1] = fixedCutoff*LFO->tick(0);
     lowPassFilter->setParams (params);
 }

 lowPassFilter->process (buffer.getNumSamples (), buffer.getArrayOfWritePointers ());

I guess that the modulation happen before the process buffer (or after, I tried to invert them) and so I can't hear the modulation. 
If I assign a slider to the cutoff and I manually move it I can hear the LFO modulating the cutoff so I know it works, I just don't know how to make it work with the buffer "always".

What can I do?

Thanks.

 

 

Try to contact Vinnie elsewhere, I have the impression he is no longer checking these forums. I am also working with his (great) stuff now, and tried to post a question to him here with his name in the topic.

I was able to to fix it myself, but still have some questions as well, eg. about some filter types missing. I guess I will contact him later by email.

BTW: you are using the filters on a low access level, via setParams. I ran into lots of problems with this approach, because the different filter families do not use the param indexes consistently. I am now using the higher level approach from the Demo, which is a lot safer (for my work).

Success!

This has nothing to do with Vinnie's filter implementation. You have to interleave the processing somehow:

Your code changes the frequency with the LFO without doing anything inbetween and applies the last coefficient set (after the for loop) on the whole buffer.

Theoretically you would iterate the buffer to calculate the coefficients and process the buffer for each sample, but this would be terribly inefficient.

But it is not necessary to calculate the frequency for each sample (this is sometimes refered to as "control rate vs sample rate") For small movements you can calculate the coefficients every 16-32 samples (check the sound for zipping noises and decrease this number until it is fine for you).

For this exact purpose I wrote a algorithm which checks the dynamic range within the modulation values and changes the control rate from 4 samples up to buffer size if nothing is going on, but maybe there are some other best practices for this task (I didn't find any resources about this subject).

1 Like

Vinnie's classes also provide Smoothed parameter scaling if you change settings, maybe also have a look at that.

For what you are trying to do, you may use the IIRFilter classes from JUCE instead, and you won't need to use smoothing classes I think. I had a look on Vinnie's DSP Filters classes a while ago, and even if they looked interesting with a lot of functionnalities, I thought they were a little complicated to use for simple tasks.

Hey lapsang,

Sorry to bring up an old topic, but did you find the solution to this in the end?

I am currently trying to accomplish the exact same thing.

Thanks,

Liam.

Aren't there functions in DSPFilter that allow you to process the filter a sample at a time instead of in blocks?  I'd start there.