Classes and objects

The principles of C++

This lecture explains how to work with C++ classes and objects, while introducing the principles of additive synthesis. The lecture explains why simple digital square and sawtooth oscillators often sound so bad, and how additive synthesis can produce a better sounding oscillator.

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
    1. Classes in C++
    2. The C++ vector class
    3. Band-limited waveform synthesis

Lecture 5: Classes and objects

What you’ll learn in this lecture

  • Basics of C++ classes
  • Working with arrays of objects
  • Principles of additive synthesis

What you’ll make in this lecture

  • An additive synthesis waveform generator

Code examples

wavetable-class: implements a wavetable oscillator using a C++ class. Includes linear interpolation and GUI controls for frequency and amplitude.

additive-synth: a partially-complete example creating an additive synthesiser with controllable amplitudes for each harmonic. In the lecture you will fill in the code to process each oscillator.

Running the examples in this course assumes that you have a Bela Starter Kit or Bela Mini Starter Kit.

This lecture does not require any other electronic hardware. However, other lectures will make use of sensors and other components. See Lecture 0 for a list of recommended parts.

Additional references

Classes in C++

The C++ vector class

Band-limited waveform synthesis