A real-time polyphonic subtractive synthesizer written in C using SDL2 and SDL_ttf.
The project contains two implementations of the same synthesizer:
subtractive_synth.c— simplified filter implementationtrue_subtractive_synth.c— more accurate biquad-based filter implementation
Both versions have identical UI and functionality, but differ in the internal filter processing algorithm.
- Polyphony (up to 8 simultaneous voices)
- Three oscillator waveforms:
- Saw
- Square
- Triangle
- Up to 5 filters in series
- Filter types:
- LPF (Low-pass)
- HPF (High-pass)
- BPF (Band-pass)
- Notch
- Real-time waveform visualization
- On-screen piano keyboard
- Octave shifting
- Dynamic filter creation and removal
Uses a lightweight state-variable style filter:
- Fast and simple
- Good for learning purposes
- Not physically accurate
- Uses internal
z1,z2states
This version is easier to understand and modify.
Implements a proper biquad IIR filter using normalized coefficients:
- Computes
b0, b1, b2, a1, a2 - Based on digital filter design equations
- More stable and realistic
- More accurate resonance behavior
This version provides a more correct subtractive synthesis approach.
Keyboard mapping:
Z S X C F V G B N J M K , L . /These keys correspond to a piano layout shown on screen.
- Press key → note on
- Release key → note off
1→ Octave down2→ Octave up
TAB→ Change waveform (Saw / Square / Triangle)
+button or=key → Add filter- Click filter → Select filter
Q→ Change filter typeUP / DOWN→ Adjust cutoff frequencyLEFT / RIGHT→ Adjust resonanceBACKSPACE→ Remove selected filter
ESC→ Exit
- SDL2
- SDL2_ttf
- C compiler (GCC / Clang)
brew install sdl2 sdl2_ttfsudo apt install libsdl2-dev libsdl2-ttf-devThe project uses a single Makefile.
Inside the Makefile, the source file is selected via the SRC variable.
Example:
# Choose one:
SRC = subtractive_synth.c #true_subtractive_synth.cTo build:
make This will compile the code and produce the executable. To run the program:
./subtractive_synth (or the name defined in the Makefile)
Or u can build and run the programm with one command:
make runTo remove compiled files and start fresh, you can use:
make clean- Sample rate: 44100 Hz
- Mono output
- Maximum 8 voices
- Maximum 5 filters in series
- The font path is currently set to a macOS system font (/System/Library/Fonts/Supplemental/Arial.ttf). Update the path if running on another OS.