Capacitor Filter Algorithm

Hi JUCE community!

I have figured out the exact low-pass capacitor filter algorithm.
It took countless tries across many many years.

It works with any number of poles.
High-pass, band-pass and band-reject are all derived from it.

Is there anybody here interested in this?

3 Likes

Yes I’m sure many of us would be interested in that :slight_smile:

2 Likes

If I understand correctly what you mean, it’s probably explained in detail here, with all sorts of additional ways to add non-linearities to it:

There’s also Moog / MS-20 / TB-303 / etc. filters explained in detal, and how to implement them in practice. Also tons of ways to optimize the algorithms are presented there.

1 Like

That’s some nice easy bedtime reading you’ve got!

1 Like

I’m not a mathematician or engineer; although that PDF is not overly complicated.

I’ve used the SVF from that PDF before and it alters the sound too much.

I use 6 if-else selection statements on every sample.
Also, it’s currently non-resonant, so it couldn’t be used in a VA synth.

I’m going to make an equalizer with it.

1 Like

That is probably due to SVF having 12 dB per octave cutoff slope, where as simple capacitor + resistor has 6 dB per octave cutoff slope.

The section 3.10 in that book seems to describe how to make the capacitor+resistor low pass filter. There’s actual code in there.

1 Like

That’s definitely a good book, and a good SVF, I’ve used that filter lots and I would use it again. But when the LPF cutoff is set 20KHz and passing all audible frequencies, I noticed that the signal sounded different than when compared to the filter being bypassed. I could be wrong though.

I used the source code from https://github.com/JordanTHarris/VAStateVariableFilter

An IIR Butterworth LPF at 20kHz will affect the audible frequency range (especially the 6 dB/oct one):

The naive implementation of that SVF from the book exhibits cramping near Nyquist. You can fix it by oversampling (and other means). Any kind of bilinear transform based model will have an issue with cramping since it maps zeroes at infinity to zeroes at Nyquist, and the workarounds are either to minimize that by making Nyquist higher (oversampling) or by trying to match the discrete time frequency response to the continuous time frequency response within that interval.

Yes, and only the sound within those frequencies should be affected.

The tangent function is used in the bilinear-transform, maybe that alters the sound a bit too; since the hyperbolic tangent function may be used as a type of saturation.

Good to know, thanks.

Also, the BPF sounds like it has a bit of overdrive, even when it’s nowhere near Nyquist.

The tangent function is used in the bilinear-transform, maybe that alters the sound a bit too; since the hyperbolic tangent function may be used as a type of saturation.

Nope! The tan is applied to the normalized cutoff frequency parameter, not the audio signal. The Bilinear transform maps a linear transfer function to a linear transfer function.

Also, the BPF sounds like it has a bit of overdrive, even when it’s nowhere near Nyquist.

The normalized bandpass from the book has a linear gain added such that the output is at unity like HPF and LPF, but it doesn’t add any distortion.

If you are hearing any distortion without explicitly adding the nonlinearities like mentioned in the book, that implies a bug.

:+1:

Definitely interested in seeing how it compares to JUCE’s State Variable Filter.