Changing the frequency content of sound
This lecture explains how to implement digital filters in C++. It introduces the terminology behind digital filters and shows how to take a filter equation and turn it into real-time code. By the end of the lecture, you will create several example filters including an adjustable resonant lowpass filter.
This lecture does not cover the mathematics of filter design; more resources on this topic are linked below.
Table of contents
- What you’ll learn in this lecture
- What you’ll make in this lecture
- Code examples
- Recommended parts
- Additional references
Lecture 8: Filters
What you’ll learn in this lecture
- Basic theory of digital filters
- Filter terminology: cutoff, bandwidth, Q, order
- Turning filter equations into code
What you’ll make in this lecture
- An adjustable resonant lowpass filter
sample-player-filter: Template for implementing digital filters. Plays an audio sample in a loop, with space in render() to implement your own filters.
resonant-lowpass: Provides the infrastructure for calculating coefficients of a resonant lowpass filter. In lecture, the filter equation will be implemented and controls will be added to adjust the cutoff frequency and Q.
Running the examples in this course assumes that you have a Bela Starter Kit or Bela Mini Starter Kit. Note that the analog outputs are only available on the original Bela board, and not on Bela Mini.
The last step of this lecture optionally uses potentiometers to adjust filter parameters. This requires the following components:
- Solderless breadboard (Rapid, Adafruit)
- 3x 10k potentiometers (Rapid, Adafruit)
- Jumper wires (Rapid, Adafruit)
- Alan V. Oppenheim and Ronald W. Shafer, Discrete-Time Signal Processing, 3rd edition. Publisher link. See also the same class on MIT OpenCourseware.
- Julius O. Smith, Mathematics of the Discrete Fourier Transform (DFT) (free online textbook).
- Julius O. Smith, Introduction to Digital Filters (free online textbook).
- Joshua D. Reiss and Andrew McPherson, Audio Effects: Theory, Implementation and Application. Publisher link.
- David Doran, An explanation of the Z-transform (YouTube video).