DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
DSPark

DSPark - header-only audio DSP in C++20

DSPark

CI Docs Release [License: MIT](LICENSE)

DSPark is a header-only C++20 audio DSP library for developers building real-time and offline audio software. It provides effects, filters, synthesis and spectral building blocks, analysis and musical tools, native file I/O, and an optional VST3/CLAP/Audio Unit v2 plugin layer.

The framework modules have no third-party dependencies and require no separately compiled DSPark library. Optimized paths may use compiler-provided SIMD intrinsics behind platform guards. The plugin adapters and the Windows-only DSParkLab application are separate from the umbrella header and carry their own platform integration requirements.

The v1.9.0 CI matrix covers Windows, Linux, macOS, WebAssembly, and an embedded profile. The framework headers also target iOS and Android, although those two platforms do not have dedicated v1.9.0 CI jobs.

Current release: v1.9.0 | API reference | Cookbook | Examples | Plugin guide

Quick start

Requirements

  • A C++20 compiler.
  • CMake 3.21 or newer when using the supplied CMake project.
  • An optimized build for production DSP (-O2 or /O2); header-only code is compiled with the flags of the consuming target.

Add DSPark to a project

Vendor the repository at third_party/DSPark, add that directory to your include path, and include the umbrella header:

#include <DSPark.h>

For a direct compiler invocation:

c++ -std=c++20 -O2 -I third_party/DSPark app.cpp -o app

For CMake, the interface target supplies the include path and C++20 requirement:

add_subdirectory(third_party/DSPark)
target_link_libraries(app PRIVATE dspark::dspark)

A CMake installation is consumed with find_package(dspark CONFIG REQUIRED) and the same dspark::dspark target. Every route (subdirectory, FetchContent, installed package) also provides the plugin layer and the dspark_add_plugin() bundle helper described in docs/plugins.md.

Or fetch the v1.9.0 release tag:

include(FetchContent)
FetchContent_Declare(dspark
GIT_REPOSITORY https://github.com/CristianMoresi/DSPark.git
GIT_TAG v1.9.0
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(dspark)
target_link_libraries(app PRIVATE dspark::dspark)

Prepare and process a block

A typical block processor is constructed and configured with prepare(AudioSpec) before its audio-stream owner calls processBlock().

#include <DSPark.h>
int main()
{
const dspark::AudioSpec spec { 48000.0, 512, 2 };
equalizer.prepare(spec);
compressor.prepare(spec);
limiter.prepare(spec);
equalizer.setBand(0, 100.0f, 3.0f);
compressor.setThreshold(-18.0f);
compressor.setRatio(3.0f);
limiter.setCeiling(-1.0f);
audio.resize(spec.numChannels, spec.maxBlockSize);
auto block = audio.toView();
equalizer.processBlock(block);
compressor.processBlock(block);
limiter.processBlock(block);
}
Owning audio buffer with contiguous, 32-byte aligned storage.
AudioBufferView< T, MaxChannels > toView() noexcept
Returns a non-owning mutable view of this buffer. The view's channel capacity is propagated from MaxC...
void resize(int numChannels, int numSamples)
Allocates the buffer for the given dimensions.
High-fidelity modular compressor designed for real-time applications.
Definition Compressor.h:104
void setThreshold(T dB) noexcept
Sets the compression threshold in dB.
Definition Compressor.h:735
void prepare(const AudioSpec &spec)
Allocates buffers and initializes internal DSP state.
Definition Compressor.h:275
void setRatio(T ratio) noexcept
Sets the compression ratio (1.0 = off, >20.0 = limiting).
Definition Compressor.h:742
void processBlock(AudioBufferView< T > buffer) noexcept
Processes an audio buffer in-place using its own signal as the sidechain.
Definition Compressor.h:391
Parametric multi-band EQ using cascaded biquads or FFT overlap-save convolution.
Definition Equalizer.h:145
void setBand(int index, T frequency, T gainDb)
Configures a band with frequency and gain (Peak filter).
Definition Equalizer.h:531
void prepare(const AudioSpec &spec)
Prepares all bands and allocates necessary resources for processing.
Definition Equalizer.h:219
void processBlock(AudioBufferView< T > buffer) noexcept
Processes an audio buffer in-place.
Definition Equalizer.h:375
High-performance brickwall lookahead limiter.
Definition Limiter.h:127
void prepare(double sampleRate, int numChannels=2, double initialLookaheadMs=-1.0)
Allocates memory and prepares the limiter for processing.
Definition Limiter.h:149
void processBlock(AudioBufferView< T > buffer) noexcept
Processes an AudioBufferView in-place.
Definition Limiter.h:265
void setCeiling(T dB) noexcept
Sets the absolute output ceiling.
Definition Limiter.h:508
Describes the audio environment for a DSP processor.
Definition AudioSpec.h:37

In an audio host, create an AudioBufferView<float> over the host-owned channel pointers instead of allocating an AudioBuffer in the callback. See the real-time-style channel-strip example and the offline WAV example for complete programs.

Capabilities

Area Representative APIs
Filters and equalization Biquad, BiquadCascade, NormalizedLadder, FilterDesign, FirBank, KeyEqualizer, LaneCascade, GraphicBank, CabinetModel, StateVariableFilter, LadderFilter, FilterEngine, Equalizer, CrossoverFilter
Dynamics and level control Compressor, Limiter, NoiseGate, Expander, DynamicEQ, MultibandCompressor, DeEsser
Offline dynamics, clipping, stereo and analysis OfflineLeveler, OfflineBeatCompressor, OfflinePeakCompressor, OfflinePunch, OfflineSoftClipper, OfflineHardClipper, OfflineStereoGenerator, OfflineStereoBalance, OfflineEnergyAnalyzer, OfflineTransientAnalyzer, OfflineTempoAnalyzer (worker API)
Nonlinear and analog modeling Saturation, MultibandSaturation, LoFi, Clipper, TapeMachine, TubePreamp, TransformerModel, CharacterStage, wdf::*
Time, pitch, and spatial processing Delay, BucketBrigade, TapeTransport, AlgorithmicReverb, Reverb, TailShaper, PitchShifter, TimeStretch, PitchCorrector, GranularProcessor
Spectral processing FFTReal, Convolver, ZeroLatencyConvolver, SpectralProcessor, SpectralFilter, DetailFilter, DetailAnalysis, SpectralEnvelope, AuditoryBands, SpectralFreeze, SpectralDenoiser, TonalBalance, ResonanceSuppressor, SpectralDynamicEQ
Analysis and metering SpectrumAnalyzer, LoudnessMeter, AudioIntervalAnalyzer, LoudnessNormalizer, PitchDetector, OnsetDetector, BeatTracker, DownbeatEstimator, LoopFinder, DelayEstimator
Synthesis and music Synthesizer (analog, FM and wavetable engines, samples, filters, envelopes, LFOs, modulation matrix), Oscillator, WavetableOscillator, WavetableBank, Sampler, Lfo, ADSREnvelope, ChordDetector, KeyDetector, harmony::*
Infrastructure AudioBuffer, ProcessorChain, Resampler, Oversampling, Dither, SpscQueue, versioned state blobs
File I/O WAV and MP3 read/write, Standard MIDI File read/write, native FLAC decode
Plugin development Native VST3 and CLAP adapters, macOS Audio Unit v2, instruments, sidechains, automation, state, and optional WebView editors

The API reference is the exhaustive class and method inventory. The cookbook covers production workflows including mastering, restoration, tempo detection, time stretching, loop finding, and pitch correction.

File I/O qualification

WAV and MP3 support includes reading and writing. MidiFile reads Standard MIDI File formats 0, 1, and 2 and writes formats 0 and 1. FlacFile is a decode-only native FLAC implementation; its write operations return false. Define DSPARK_NO_FILE_IO before including DSPark.h to omit all file-I/O headers for targets without filesystem support.

Real-time and threading contract

Real-time safety is a per-method contract, not a blanket property of every operation:

  • Construction, prepare(), state restoration, and setup-only configuration may allocate and must not run concurrently with processing.
  • A prepared processor has one audio-stream owner. Processing methods that a component documents as real-time-safe avoid allocation and unbounded waits; offline utilities are outside that contract.
  • Parameter publication normally assumes one control writer and one audio owner. Some setters are safe during processing; setup setters such as changes that resize oversampling storage are not.
  • Before sharing an instance, read its documented threading contract. Report the latency of lookahead, FFT, convolution, and oversampled paths to the host.

The complete ownership and publication rules are in the threading model.

Platform and validation coverage

Target v1.9.0 validation
Windows MSVC x64 and ARM64: test and conformance suites
Linux GCC x64/ARM64 and Clang x64: test and conformance suites
macOS Clang ARM64: test and conformance suites
WebAssembly Emscripten conformance in scalar and SIMD128 configurations
Embedded profile GCC compile gate with file I/O, exceptions, and RTTI disabled
iOS and Android Portable framework headers; not separate targets in the v1.9.0 CI matrix

CI also checks installed-header self-sufficiency with GCC and Clang, warning-free builds, sanitizers, concurrent publication paths, examples, native plugin smoke hosts and validators, and generated documentation. The official EBU loudness-vector job is best effort because the licensed test material is downloaded separately; the job reports a skip when the vectors are unavailable.

Measured processor and analyzer results, including settings and limitations, are published in the quality metrics table.

Native plugins

DSPark supplies native adapters for VST3 and CLAP on desktop platforms and Audio Unit v2 on macOS. The required VST3 C API and CLAP headers are included in the repository; the CMake helper builds the platform-specific module or bundle layout.

The shared plugin contract covers parameters, automation, state, latency, tail reporting, bypass, mono/stereo layouts, sidechains, transport, MIDI instruments, offline-rendering modes, and factory presets. Custom editors can be written in HTML/CSS/JavaScript and embedded with the platform WebView layer. On Linux, a custom editor requires WebKitGTK at runtime; the host's generic parameter UI remains the fallback when a WebView is unavailable.

Start with the plugin guide and the plugin examples.

DSParkLab

DSParkLab/ is a Windows-only Win32/Direct3D 11 application for interactive processor testing. Its bundled Dear ImGui and miniaudio sources are confined to the application and are not dependencies of the DSPark framework. For the selected effect it draws the spectrum under the effect's response or its live gain curves (with what a spectral processor detects), the gain reduction over time, the output meters and a test tone with its THD+N, and lays the controls out as knobs on tabs. Space plays and pauses, B switches between the processed and the dry signal, E puts the selected effect in or out of the chain and R resets its controls. Started as DSParkLab.exe Compressor, it opens with that effect shown; it draws at the resolution of the monitor it is on. Build it with DSParkLab\build.bat (Visual Studio 2019 or later, any edition).

Documentation

What's new in v1.9.0

  • New effects: TonalBalance, an adaptive equalizer driven by a model of hearing; ResonanceSuppressor; SpectralDynamicEQ; MultibandSaturation; and LoFi.
  • New analysis: DownbeatEstimator, which finds the first beat of each bar and the metre.
  • New building blocks: FilterDesign and BiquadCascade (analog-matched filters of any order and slope), KeyEqualizer (a sidechain equalizer for the dynamics), DetailFilter and DetailAnalysis (a spectral engine with a detail control), BucketBrigade, TapeTransport, CabinetModel, CharacterStage, TailShaper, NormalizedLadder and more.
  • New options in the compressor, the gates, the equalizers, the reverbs, the tape, the chorus and the saturators.
  • Improvements across the library in sound quality, accuracy, speed and robustness.

v1.9.0 is source compatible with v1.8.1. Some defaults and latencies change: see the v1.9.0 migration guide, the release notes and the full changelog.

What's new in v1.8.1

  • Synthesizer: a polyphonic synthesizer with analog (three band-limited oscillators, PWM, hard sync), four-operator FM and morphing wavetable engines. Every engine can also play samples, so a recorded note goes through the synthesizer's ladder or state-variable filter, envelopes, LFOs, modulation matrix and unison. Events are sample-accurate, renders are identical for any block size, and 2x/4x oversampling is optional.
  • Better synthesis building blocks: a 128-tap minimum-phase MinBlepTable (saw and pulse aliasing at -143 dB or lower), Oscillator pulse-width modulation with a double-precision phase, WavetableBank mipmapped tables for WavetableOscillator (about -165 dB), and the new Lfo.

Read the release notes and the full changelog. Upgrading from v1.7.0 is covered by the v1.8.0 migration guide.

Build and contribute

From a repository checkout:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
ctest --test-dir build --build-config Release --output-on-failure

Contributions are welcome. Read CONTRIBUTING.md for the development workflow and conventions. Please open an issue to discuss a proposed change before submitting a pull request. Bug reports should include the platform, compiler version, and a minimal reproduction.

License

DSPark is available under the [MIT License](LICENSE).

Author

Created and maintained by Cristian Moresi. Contact: dev@cristianmoresi.com.