Filters

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

  1. What you’ll learn in this lecture
  2. What you’ll make in this lecture
  3. Code examples
  4. Recommended parts
  5. 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

Code examples

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:

Additional references