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
- What you’ll learn in this lecture
- What you’ll make in this lecture
- Code examples
- Recommended parts
- Additional references
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.
Recommended parts
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++
- Online tutorial: C++ Classes at cplusplus.com
- YouTube video: C++ Tutorial for Beginners by freeCodeCamp.org
The C++ vector
class
vector
reference documentation
Band-limited waveform synthesis
- Paper: T. Stilson and J. O. Smith, Alias-Free Digital Synthesis of Classic Analog Waveforms, International Computer Music Conference, 1996.
- Video: The amazing usefulness of band limited impulse trains, shown for oscillator banks, Stefan Stenzel, Audio Developer Conference 2017.
- Blog post: Band-limiting techniques for digital oscillators (metafunction.co.uk)
- Book: Beat Frei, Digital Sound Generation, Institute for Computer Music and Sound Technology (ICST), Zurich University of the Arts, 2019