Low pass filter (revisited)02 Jul 2017
Recently I’ve examined in depth the theory behind digital filters and I think I’ve eventually understood what is going on at page 183 of Andy Farnell’s Design Sound book. Indeed, at the end of chapter 10, Andy talks about a way to filter out quick fluctuations on a floating point number stream.
This patch, he says, is a simple low pass filter that follows this filter equation:
The strenght of the filter is set by the ratio . Both and should be between and and add up to .
This patch was earlier mentioned here while now I would like to continue examing it in more depth.
As I said earlier now that I’ve acquired greater certainty on the subject I want to fix here some of the things I consider to be important to remember.
First of all, this patch is an implementation of a recursive filter, i.e. a filter which feed back its previuos output to compute the next one.
Let’s examine the general case first (see Miller section 7.4 Recirculating Delay network
Here we add the incoming signal to a delayed copy of itself but, prior to do that, we multiply the latter by a gain factor. Here d is the delay time and g is the feedback coefficient.
In order to keep this network stable, g must be lesser than 1!
The frequency response of such a delay netwrok configuration is shown in the image below:
Then note that at DC and multiples the gain is .
Now lets reduce the delay time to a single sample (Miller section 8.2.3 Elementary recirculating filter and Pirkle section 5.15 First-Order Feed-Back Filter Revisited), and draw a new diagram of the same recirculating filter:
(Don’t mind if some symbols look different from the diagram we’ve seen before, essentially the working principle is the same: the incoming signal is added with a deleyad copy of itself. The delay last only 1 single sample and the delay copy is scaled down usign g, the feedback coefficient.)
The frequency response is similar to the one from before, the only difference is in where these peaks are:
Now the peaks are located at multiples which means we have a peak at DC and one at Nyquist (). If we concentrate our attention only on the audible spectrum (approximately from 0 to radians) we can see this delay network behaves like a low pass filter!
Now, what about if we want unity gain at these peaks? We can multiply the input signal for a normalization factor of :
An interesting thing to note here is the place we inserted the normalization factor: we placed on the input side instead of the output. Even if in theory it would have been the same thing, we need to consider some side effects as described by Miller in section 8.3.9 Time varying coefficients.
Now let’s pause for a moment and look back where we started. Now its clearer where the theory behind Farnell patch comes from: the coefficient is indeed the feedback coefficient of a recirculating delay network (g) while , used to multiply the input, is the normalization factor (we saw its value is equal to ).
Now the formula below becomes pretty starightforward
it is indeed the same as
Now is also clear why (and ) must be lesser than one and and must sum up to 1: this is the “recipe” to build up a low pass filter!
But how to set g in order to get a filter with the exact cutoff frequency we want?
Cut frequency eveluation
On how to solve this problem, I suggest to take a look to the theory (Miller section 8.3.1 One-pole low-pass-filter) while here we can make the long story short.
We can say that, for geometrical considerations on the complex plane (see image below),
…if we consider an half power pulsation which is relatively small, we can also write:
which implies that, beeing the sampling frequency, we can obtain the cut frequency () from the relation below:
which can be further transformed into
Using this formula we can get both the normalization factor and the feedback coefficient, having the cutoff frequency and the sampling rate!
Here are some of the resources which helped me the most to understand the subject:
- Will Pirkle’s Designing Audio Effect Plug-in in C++ - 2013, Focal Press;
- Miller Puckette’s The theory and Technique of Electronic Music