What is an allpass filter? What is it used for?
An allpass filter is a filter with a unity gain across all frequencies. This means that no frequency passing through that filter will be boosted or attenuated. It introduces, however, a frequency-dependent delay.
So although the output of an allpass filter doesn’t sound different from the input, this simple structure used in conjunction with other elements has an incredible power, which is present in almost all music software.
A digital allpass filter can be implemented as a finite-impulse response (FIR) filter or an infinite-impulse response (IIR) filter, typically of the first or the second order. Its applications are manifold: it is used to implement
- artificial reverberation,
- filters (e.g., highpass, lowpass, notch),
- audio effects (e.g., phaser),
- phase equalization, and more.
In this article, we will discuss the digital allpass filter in detail, present its various forms, provide their characteristics, schematics, and implementation, and, finally, discuss how you can use the allpass filter in your musical software like VST or AAX plugins.
In Short
Allpass Filter
- An allpass filter has gain equal to 1 at all frequencies.
- It delays all frequency components of the input, each by its own phase shift.
- It comes in various forms, but the most popular are first- and second-order IIR forms.
- It is a building block of a huge number of audio processing algorithms, like reverbs or filters.
Table of Contents
- Definition of an Allpass Filter
- Types of Allpass Systems
- Applications of Allpass Filters
- Example Allpass VST Plugin
- Summary
- Bibliography
Definition of an Allpass Filter
An allpass filter is a filter which does not change the magnitude of any frequency component that passes through it [2].
Formally, if we denote the transfer function of an allpass filter by
But wait, since the magnitude does not change, what do we need allpass filters for? We need them, because they introduce a frequency-dependent phase delay. In other words, we are able to manipulate the phase of the frequency components without altering their magnitude.
Note: A transfer function of a digital filter is a Fourier transform or a
Types of Allpass Systems
There are many types of systems that have the allpass property. They can be roughly divided into FIR and IIR categories.
FIR Allpass System
The simplest allpass filter is the delay [4]
where
Figure 1. Block diagram of an FIR allpass filter.
A broader description of the properties of the delay can be found in my article.
First-Order IIR Allpass
A first-order IIR allpass filter is given by the following transfer function [2,3,4]
where
where
Implementation
The difference equation 3 is equivalent to the following DSP diagram.
Figure 2. Block diagram of the first-order allpass filter.
How to see the equivalence? First, observe that we have here a combination of two comb filters: a feedback and a feedforward comb filter [4].
Feedback comb filter difference equation:
Feedforward comb filter difference equation:
Second, insert
Finally, replace the first
which is equivalent to Eq. 3.
Magnitude Response
Why is this system allpass? Let’s calculate its magnitude transfer function at the unit circle, i.e., its magnitude frequency response or
where
Phase Response
What is the role of the
Figure 3. Phase response of a first-order allpass filter for different break frequencies
We here refer to the digital frequency, i.e., the ratio of the frequency
The blue dashed lines in the figure mark the break frequencies of particular curves. The red line marks the phase shift by
How are Equations 2 and 9 derived? They are the result of transforming an analog allpass filter to the digital domain via the bilinear transform. Explaining this process is beyond the scope of this article; if you are interested, check out a great explanation in [4]. After the derivations, we arrive exactly at the transfer function from Equation 2 with the coefficient
How are the plots in the above figure generated? They are derived from the argument (in the complex numbers sense) of the allpass transfer function freqz
function of Matlab or scipy.signal
. Alternatively, you can use the following out-of-the-box formula [5]
Derive It Yourself?
Why am I saying that the formula in Equation 10 is out-of-the-box? I wasn’t able to derive it myself. After manual calculations, however, I managed to obtain a formula which was equivalent in terms of the plots. Comparison against freqz
also yielded an identical result.
Do you know how to derive Equation 10? If so, please, let me know in the comments!
Properties of the First-Order Allpass Filter
When you look at the figure with the phase response of the first-order allpass filter, you can read out interesting properties.
- The phase shift at DC (
) is 0. - The phase shift at the Nyquist frequency (
) is rad and is always the maximum phase delay. - The phase shift at the break frequency
is rad.
Cascading Allpass Filters
Arranging allpass filters in a series results in the summation of phase delays. We can therefore obtain a phase delay of
Second-Order IIR Allpass
The second-order IIR allpass filter has the following transfer function [3]:
where the parameter
where
Note how
Phase Response
The phase response of the second-order allpass filter with different break frequencies
Figure 4. Phase response of a second-order allpass filter for different break frequencies frequencies
As you can see above, the break frequency determines the point of the phase shift by
If instead, we keep the break frequency constant and change the bandwidth parameter, we obtain the following phase responses:
Figure 5. Phase response of a second-order allpass filter for different bandwidths
The curvature of the slope gets milder with the increasing
What do these plots really show? They show that the second-order allpass filter is an incredibly flexible tool. We can independently change meaningful parameters such as the break frequency or the bandwidth while ensuring the filter’s stability. This property is crucial for implementing parametric filters (parametric equalizer, EQ), because we want to be able to change a filter’s properties in an intuitive and safe manner.
Implementation
The difference equation of the second-order allpass is [3]
If that seems complicated, a diagram should make it clear 🙂
Figure 6. Block diagram of the second-order allpass filter.
Properties of the Second-Order Allpass Filter
The second-order allpass filter has the following properties:
- The phase shift at DC (
) is 0. - The phase shift at the Nyquist frequency (
) is rad and is always the maximum phase delay. - The phase shift at the break frequency
is rad. - We can control the break frequency
and the bandwidth independently. This is not possible with the first-order allpass: there, the higher the break frequency, the less steep the slope.
Higher-Order IIR Allpass Filter
You may have noticed a kind of symmetry in Equations 2 and 11. Indeed, it turns out that every IIR allpass filter must have a transfer function of the form [4]
where
Note that we added here a possible phase inversion and an additional delay. Thus, this formulation is 100% general and can be applied to every real-valued case.
However, higher-order allpass filters are rarely used in practice of audio programming, because their usage requires complicated analysis and, in most cases, first- and second-order IIR allpass filters suffice.
Applications of Allpass Filters
Although for the single-channel audio, we cannot hear the effect of the phase delay, allpass filters are incredibly useful in musical applications. Why?
- They are stable.
- They have a meaningful parameters-to-coefficients mapping (e.g., break frequency to the
coefficient in the second-order allpass). - They are computationally efficient.
- Their properties are well-examined.
How can we use them in audio processing? For example, what happens if we add two sines at the same frequency: one delayed by
Where can we use the properties of allpass filters? Below are some selected applications.
Reverberation
Allpass filters are heavily used in artificial reverberation: an effect creating the impression of listening to music in some space (e.g., a room, a concert hall) [4]. Allpass filters are present in some established approaches to simulate reverberation.
The Schroeder reverberator consists of a series of allpass filters, a parallel bank of feedback comb filters, and a mixing matrix [4]. It was proposed as early as 1962!
The Freeverb algorithm uses a parallel bank of feedback comb filters and a series of allpass filters [4].
Note: If you are interested in how to implement the Freeverb using Rust, check out this video with Ian Hobson (ex-Ableton).
Parametric Equalizer
Have you ever wondered, how are highpass, lowpass, shelving, notch or bandpass filters implemented in digital audio workstation (DAW) plugins? Well, I bet most of them use the RBJ Cookbook as a foundation. The RBJ Cookbook is a set of recipes for stable, controllable, and efficient filters of any type. It turns out, that all these recipes use first- or second- order allpass filters underneath! More details on how to derive these formulae can be found in [3]… but I hope you will be able to read about them on WolfSound as well soon 🙂.
Phaser
Do you know what’s the effect applied to guitars on Van Halen’s Eruption? That’s a phaser: an effect that sweeps notches through the spectrum of the input signal. One of the ways to implement a digital phaser is to use a chain of allpass filters, whose output is summed with the unfiltered input signal [3,4,5].
Phase Equalization
Different microphones may introduce different frequency-dependent delays. Mixing their signals via summation could cause phase cancellation regardless of whether we invert the phase of one of the signals or not. We can prevent it only by selectively adjusting the phase delay of the frequency components of one of these signals. What is the system that can change the phase delay without changing the magnitude of a frequency component? I hope that you know the answer by now 🙂.
Example Allpass VST Plugin
In Reaper’s ReaEQ VST plugin, there is an allpass filter available.
Figure 7. Allpass filter in the Reaper’s ReaEQ VST plugin.
How to observe the frequency-dependent phase cancellation with a parallel allpass? Here’s a quick tutorial:
Figure 8. Application of a parallel allpass filter with ReaEQ to create a notch.
Steps to reproduce:
- Load an audio track to Reaper and duplicate it.
- Add Reaper’s ReaEQ VST plugin to one of the tracks.
- Open the plugin and remove all but 1 frequency bands.
- Change the type of the remaining frequency band to “All Pass”.
- While listening to the master track, change the “Frequency [Hz]” parameter of the allpass. Can you hear the notch in the frequency spectrum?
- You can also load ReaEQ on the master track and observe the notch there.
Have fun! 🎧
Summary
In this article, we have discussed an allpass filter. Now, you understand
- what is an allpass filter,
- what types of musically useful allpass filters exist,
- how to implement them,
- how they are applied in various effects,
- how to use an allpass filter in a DAW.
Thank you for reading! If you enjoyed the article and want to learn even more, sign up for my newsletter! You will become an expert in digital audio effects without the need to read thick books on DSP.
If you have any questions, don’t hesitate to ask them below!
Bibliography
[1] Alan V. Oppenheim, Alan S. Willsky, with S. Hamid Signals and Systems, 2nd Edition, Pearson 1997.
[2] Alan V Oppenheim, Ronald W. Schafer, Discrete-Time Signal Processing, 3rd Edition, Pearson 2010.
Links above may be affiliate links. That means that I may earn a commission if you decide to make a purchase. This does not incur any cost for you. Thank you.
Comments powered by Talkyard.