Hacker News new | ask | show | jobs
by thu 2824 days ago
Maybe someone here can help.

A few years ago I tried to implement what is shown on that page but without using something like SC, i.e. I was generating list of samples directly. I recall I was stuck trying to find how the 2nd order resonant Low Pass Filter (BLowPass [1]) was working.

Any good pointer to help me write it would be appreciated. I didn't spent much time reading SC source but I think it was not very clear for me without much sound synthesis knowledge.

1. http://doc.sccode.org/Classes/BLowPass.html

2 comments

A typical implementation is simple - a couple of single sample delays, a couple of multiplications, some addition.

Deriving the coefficients and the design is not simple. There is math.

https://ccrma.stanford.edu/~jos/filters/Two_Pole.html

A characteristic equation called the Transfer Function defines what a filter (actually any circuit) does using polar complex numbers to represent the frequency and phase of an arbitrary input signal.

Basically the TF says "If you put a sine wave in, the circuit will change its amplitude and phase like this" - across all possible frequencies.

Filters are usually designed with a combination of poles and zeroes.

Poles are low-pass building blocks. Zeroes are high-pass building blocks.

Poles are a polynomial on the denominator of the Transfer Function, zeroes a polynomial on the numerator.

When you have your continuous Transfer Function you apply something called a z-transform, which gives you a form you can turn into a difference equation, which is basically the core equation for the filter, and another set of equations for calculating the coefficients.

Instead of deriving this from scratch you use standard forms which you can find on sites like the JOS tutorial I linked to, and dspguru.com.

But you do need to have some idea how all of this works - and also when this nice simple model stops working. (E.g. digital filters have issues close to the sampling rate, so good designs compensate for this and don't just use the difference equation blindly.)

Thanks a lot. It seems this remains quite a challenge to turn those into working code though !
Here is my code.

https://github.com/kbob/deep-synth

Specifically, look at experiments/deep-svf.c. If SVF is not defined, it uses a C translation of the Supercollider BLowpass2 algorithm. If SVF is defined, it uses a Chamberlin state variable filter (SVF).