Having various issues with the DSPFilters library

Since it seems @TheVinn is no longer active, I thought I’d try my luck and posting here since presumably many here have a lot of experience with DSPFilters.

I’m having some issues with implementing high pass and low pass filters into my most recent plugin.

The firs tissue is that it appears the High Pass Filters from Dsp::SimpleFilter appear to not work consistently across different sample rates. I have checked and double checked that every time the DAW’s samplerate changes, I call .setup() on the filter with the new sampleRate as a parameter. It still seems to be the case that the slope on the high pass filter becomes considerably less steep when you transition from say 48000 to 96000, letting probably far too much sound below the cutoff through on the higher sample rates (either that, or the cutoff frequency is being inexplicably lowered).

My second issue concerns changing the cutoff frequency for any of the main filter types (using butterworth currently) in real time. At the moment I’ve been having to call .setup() every process block while the cutoff frequency is changing to change the filter’s cutoff, but this introduces noise (not zipper noise exactly, but some kind of other distortion). Even if I interpolate the changes to the cutoff frequency variable (e.g. by using the LinearSmootherValue class) it still introduces noise, is there a better way to smoothly change the cutoff frequency?

My last issue is regarding latency. I think these filter can introduce a few samples of delay, is it possible to get an exact measure of how many samples the filter is delaying the audio by, so I can use setLatencySamples() with it to notify the host?

Any help on these issues would be greatly appreciated.

After peaking at the classes on github it looks like the author didn’t pre-warp the cutoff frequency in the coefficient calculations. wd = tan (pi * fc/fs) where wd is the pre-warped digital cutoff frequency that maps to the desired fc, analog cutoff frequency for a desired fs. Tangent calls are expensive, you can check out the musicdsp archive for some decent approximations.

With your second problem, try interpolating the filter coefficients and not the filter parameters.

For the third problem, as IIR filters are inherently non-linear phase, the group delay is not constant. So the “latency” of your plugin is going to vary with frequency. If you want an average measure of a given filter, you’ll need to calculate the group delay and find its average. Here’s a good walkthrough.

If you are worried about maintenance, use another library that is still maintained, like Audio ToolKit.
Also, on top of the prewarp (which which should probably be called unwrap), you have to remember that for a low pass, at Nyquist, you have infinite reduction, so the slope has to be stronger for 48kHz than for 96kHz for the same cut frequency.

You also don’t necessarily have to have a lowpass with infinite reduction at Nyquist, that’s just a consequence of mapping a zero at s = inf to z = -1. There are ways around it.

I assume you mean this? https://www.kvraudio.com/product/audio-toolkit-by-matthieu-brucher - do you know how well the library works with Juce? It appears the author himself was having trouble implementing it here: http://blog.audio-tk.com/2017/05/02/using-audio-toolkit-with-juce-5/

p.s. I’m aware about low pass approaching nyquist, but my issue with the sample rate is with the high pass :slight_smile:

edit: oops, just noticed you ARE the author heh - so it’s compatible with JUCE now?

Yeah :wink:
It works fine from the start (I published my last plugins with it), it’s just that adding the libraries is cumbersome, as I didn’t create a dedicated JUCE module yet. I need to check how to do it and then make a tutorial to set up the folder hierarchy for them.

1 Like

It is really not difficult and totally worth it. Here is the documentation:

Would help the people to use it, looking forward to it.

1 Like

A JUCE module would be awesome, I’d be very happy to help test it for you.

Thanks. I’ll keep this in mind. Lots on my plate at the moment (moving to a new city). I just added cmake projects support, so it makes sense to add the juce module file as well. Just a matter of time :confused:

not sure if any of you got the email about JUCE ADC, but it said that the juce DSP module was going to be released July 29th or so.

Indeed, I just read it again:

Not sure using a Vec4 class is a good idea when you have AVX1/2/512. This is where you should let the compiler do its magic instead.