sndfilter
Algorithms for sound filters, like reverb, dynamic range compression, lowpass, highpass, notch, etc.
It's easy to find countless math equations on sound filters, but a bit harder to find simple source code. This library is my attempt at cleaning up and presenting the math-heavy filter algorithms for the programming community.
(MIT License)
Build Instructions
The ./build
script is a simple bash script that compiles the source files using clang
. It's
dirt simple, I promise.
Simply run ./build
and the executable should be ./tgt/sndfilter
.
Filters
- Reverb (Algorithmic)
- Compressor
- Low-Pass (Cutoff, Resonance)
- High-Pass (Cutoff, Resonance)
- Band-Pass (Frequency, Q)
- Notch/Band-stop (Frequency, Q)
- Peaking (Frequency, Q, Gain)
- All-Pass (Frequency, Q)
- Low Shelf (Frequency, Q, Gain)
- High Shelf (Frequency, Q, Gain)
Implementation
The reverb.c, compressor.c, and biquad.c are the core algorithms.
I do not understand the biquad math, so please don't ask me any questions :-). The core formulas were extracted from Biquad.cpp (Chromium source), and cleaned up a bit to make easier to read.
The compressor came from DynamicsCompressorKernel.cpp (also from Chromium), and cleaned up a bit more. I swapped out the adaptive release curve and simplified the knee calculations. I feel a little more comfortable with that algorithm because there isn't a whole lot of magical math involved.
The reverb effect is a complete rewrite of Freeverb3's Progenitor2 algorithm. It took quite a lot of effort to tear apart the algorithm and rebuild it, but I'm pretty sure it's right.