Circular buffers

Delay effects and continuously writing to memory

This lecture introduces circular buffers as a way to save the previous history of an audio signal. Circular buffers can be used to create delays and delay-based audio effects such as echo, chorus and flanger effects. Over the course of the lecture, we progressively build up a circular buffer example with adjustable delay and feedback.

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. Further reading

Lecture 11: Circular Buffers

What you’ll learn in this lecture

  • Keeping track of previous audio samples
  • Why and how to use circular buffers
  • Creating an audio delay

What you’ll make in this lecture

  • An adjustable delay and an echo effect

Code examples

circular-buffer: Template project which is built up in several steps over the lecture. Plays a sound file in a loop. During the lecture we implement a circular buffer with read and write pointers and adjustable delay.

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.

Further reading

More information on delay-based audio effects, including vibrato, chorus, flanger and echo, can be found in Chapter 2 of this textbook:

  • Joshua D. Reiss and Andrew McPherson, Audio Effects: Theory, Implementation and Application. Publisher link.