Skip to content

bradhowes/DSPHeaders

Repository files navigation

CI COV License: MIT

Overview

Swift package containing useful C++ v23 headers for AUv3 app extensions and digital signal-processing (DSP) in general. These were written specifically for use in an audio unit render thread, so there are no memory allocations done once a render thread is started. Although it is is all C++, it does have instrumentation to support Swift C++ interoperability. The demo application of the [auv-support][auv3-support] package illustrates how to use the headers to create an AUv3 DSP kernel (the kernel just attenuates the input signal -- basically a volume control knob).

The EventProcessor template in the DSPHeaders product serves as the basis for all AUv3 audio rendering kernels. The EventProcessor::renderFrames method is the sole place that invokes doRendering, and it properly handles ramping of AUv3 parameter changes. Continuing up the call chain, the EventProcessor::render method invokes renderFrames while properly interleaving calls to it with MIDI event and parameter change processing.

You only need to define your own doRendering method to perform the sample rendering. Pretty much everything else is handled for you. You can define additional methods if you wish, but only the doRendering one is mandatory.

Instead of using C++ virtual functions to dispatch to functionality held in derived classes, EventProcessor relies on the derived class being given as the template parameter. This setup is known as the "curiously recurring template pattern" (CRTP). The template also uses modern C++ traits techniques to detect if methods are present in your class, and the compiler only generates code to call them when they are available.

This collection was originally part of my AUv3Support package, but with that repo being deprecated this is now on its own.

Credits

All of the code has been written by myself over the course of several years working on AUv3 app extensions. There are a collection of routines in ConstMath that provide compile-time values for sine, natural log, and exponential function. These are used to generate some lookup tables at compile time. The functions that do this were taken from Lakshay Garg's compile_time (no specific license) repo and Keith O'Hara's GCEM (Apache license) repo. I started off with compile_time but I lifted the natural log function from GCEM. Note that the use of these compile-time methods are only for a very limited set of use-cases, all of which are not that demanding in terms of precision.

About

Collection of C++ headers for DSP work with AUv3 components

Resources

License

Stars

Watchers

Forks

Packages

No packages published