bbx_dsp
A block-based audio DSP system for building signal processing graphs.
Features
- Graph-based architecture: Connect blocks to form processing chains
- Generic sample type: Works with f32 or f64 precision
- Realtime-safe processing: Stack-allocated buffers, no allocations in audio thread
- Parameter modulation: LFOs and envelopes can modulate block parameters
- Parameter smoothing: Click-free parameter changes with configurable ramp times via
set_smoothing() - Topological sorting: Automatic execution order based on connections
Block Types
Generators
OscillatorBlock- Waveform generator (sine, square, saw, triangle, pulse, noise)
Effectors
GainBlock- Level control in dBOverdriveBlock- Asymmetric soft-clipping distortionPannerBlock- Stereo, surround (VBAP), and ambisonic panningDcBlockerBlock- DC offset removalChannelRouterBlock- Simple stereo channel routingChannelSplitterBlock- Split multi-channel to mono outputsChannelMergerBlock- Merge mono inputs to multi-channelMatrixMixerBlock- NxM mixing matrixAmbisonicDecoderBlock- Ambisonics B-format decoderBinauralDecoderBlock- Ambisonics B-format to stereo binaural for headphonesLowPassFilterBlock- SVF-based TPT low-pass filter with cutoff/resonance
Modulators
LfoBlock- Low-frequency oscillator for parameter modulationEnvelopeBlock- ADSR envelope generator
I/O
FileInputBlock- Read audio from filesFileOutputBlock- Write audio to files (non-blocking I/O)OutputBlock- Terminal graph output
Multi-Channel System
Beyond basic stereo, bbx_dsp supports surround and ambisonic formats:
Channel Layouts
Mono- 1 channelStereo- 2 channels (default)Surround51- 6 channels (5.1)Surround71- 8 channels (7.1)AmbisonicFoa- 4 channels (1st order)AmbisonicSoa- 9 channels (2nd order)AmbisonicToa- 16 channels (3rd order)Custom(n)- Arbitrary channel count
Channel Config
Blocks declare how they handle multi-channel audio:
Parallel(default) - Process each channel independentlyExplicit- Block handles routing internally (panners, mixers, decoders)
Use GraphBuilder::with_layout() to create graphs with specific channel configurations.
Cargo Features
simd
Enables SIMD optimizations for supported blocks. Requires nightly Rust.
[]
= { = "...", = ["simd"] }
Optimized blocks:
OscillatorBlock- Vectorized waveform generationLfoBlock- Vectorized modulation signal generationGainBlock- Vectorized gain application
PluginDsp Trait
For plugin integration, implement PluginDsp with optional MIDI support:
process()receivesmidi_events: &[MidiEvent]parameter- Override
note_on(),note_off(),control_change(),pitch_bend()for MIDI handling
Benchmarking
Run performance benchmarks to measure SIMD optimization effectiveness:
# Scalar baseline
# SIMD comparison (requires nightly)
HTML reports are generated in target/criterion/. See the full documentation for details.
Usage
use ;
// Create a graph with 44.1kHz sample rate, 512 sample buffer, stereo output
let mut builder = new;
// Add an oscillator
let osc = builder.add_oscillator;
// Build the graph (automatically adds output block)
let mut graph = builder.build;
// Process audio
let mut left = vec!;
let mut right = vec!;
let mut outputs: = ;
graph.process_buffers;
License
MIT