bbx_dsp
A block-based audio DSP system for building signal processing graphs.
Overview
bbx_dsp is the core DSP crate providing:
- Graph-based architecture for connecting DSP blocks
- Automatic topological sorting for correct execution order
- Real-time safe processing with stack-allocated buffers
- Parameter modulation via LFOs and envelopes
Installation
[dependencies]
bbx_dsp = "0.1"
Features
| Feature | Description |
|---|---|
| Graph | Block graph and builder |
| Block Trait | Interface for DSP blocks |
| BlockType | Enum wrapping all blocks |
| Sample | Re-exported from bbx_core |
| DspContext | Processing context |
| Parameters | Modulation system |
Quick Example
#![allow(unused)] fn main() { use bbx_dsp::{ blocks::{GainBlock, OscillatorBlock}, graph::GraphBuilder, waveform::Waveform, }; // Create a graph: 44.1kHz, 512 samples, stereo let mut builder = GraphBuilder::<f32>::new(44100.0, 512, 2); // Add blocks let osc = builder.add(OscillatorBlock::new(440.0, Waveform::Sine, None)); let gain = builder.add(GainBlock::new(-6.0, None)); // Connect: oscillator -> gain builder.connect(osc, 0, gain, 0); // Build the graph let mut graph = builder.build(); // Process audio let mut left = vec![0.0f32; 512]; let mut right = vec![0.0f32; 512]; let mut outputs: [&mut [f32]; 2] = [&mut left, &mut right]; graph.process_buffers(&mut outputs); }
Block Categories
Generators
Blocks that create audio signals:
OscillatorBlock- Waveform generator
Effectors
Blocks that process audio:
GainBlock- Level controlPannerBlock- Stereo panningOverdriveBlock- DistortionDcBlockerBlock- DC removalChannelRouterBlock- Channel routing
Modulators
Blocks that generate control signals:
LfoBlock- Low-frequency oscillatorEnvelopeBlock- ADSR envelope
I/O
Blocks for input/output:
FileInputBlock- Audio file inputFileOutputBlock- Audio file outputOutputBlock- Graph output
Architecture
The DSP system uses a pull model:
GraphBuildercollects blocks and connectionsbuild()creates an optimizedGraph- Topological sorting determines execution order
process_buffers()runs all blocks in order
See DSP Graph Architecture for details.