Skip to main content

Crate bosai_dsp

Crate bosai_dsp 

Source
Expand description

Beat-synced DJ effects, in pure Rust.

A library of DSP building blocks modelled on the Beat FX section of a professional DJ mixer: effects whose time base is musical rather than absolute. Every time-based effect here takes a beat_value (in beats) plus a live BPM, and derives its own delay time, loop length, or LFO rate from them — so a 1/2-beat echo stays a 1/2-beat echo when the deck’s tempo fader moves.

That is the distinction from general-purpose audio DSP crates, which overwhelmingly express time in seconds and leave tempo mapping to the caller.

§What’s here

Beat-synced effects — all take set_bpm() + beat_value:

  • echo — stereo echo with DJ-mixer pre-filter variants (HPF / LPF / BPF)
  • ping_pong — cross-fed L/R bouncing delay
  • roll_fx — Roll, Slip Roll, Rev Roll and Helix buffer loopers
  • gater — rhythmic gate with noise fill
  • filter_fx — resonant HP/LP filter with beat-rate LFO sweep
  • flanger, phaser, peak_filter — beat-rate modulated

Free-running blocks:

  • reverb — Freeverb, RT60-parameterised
  • eq_chain — 3-band Linkwitz-Riley crossover EQ + sweep filter
  • biquad, svf — filter primitives
  • smoother — one-pole parameter smoothing
  • resample — linear/cubic interpolation helpers

§Conventions

Stereo only. CHANNELS is fixed at 2. Every DJ mixer signal path is stereo, and fixing it keeps frames on the stack as [f64; 2] with no allocation on the audio path.

f64 internally. Effects process in f64 and are intended to sit in an f64 mix bus; convert at the device boundary.

Click-free by construction. Parameter changes are smoothed with one-pole filters, and changes that would jump a read pointer (delay time, beat value) are handled with short equal-power crossfades rather than discontinuities. Filter state is deliberately not reset on parameter change.

No allocation on the audio path. Buffers are sized once at construction from a documented maximum; process() never allocates.

Modules§

biquad
Second-order IIR biquad filter.
echo
BPM-synced stereo echo with optional pre-filter variants.
eq_chain
3-band parallel crossover EQ + SVF sweep filter.
filter_fx
Beat FX: resonant filter with LFO-modulated cutoff.
flanger
Beat FX: Flanger.
freeverb
Freeverb — a Rust implementation of the public-domain Freeverb reverb algorithm.
gater
Beat FX: Gater.
peak_filter
Beat FX: Peak Filter.
phaser
Beat FX: Phaser.
ping_pong
Beat FX: Ping Pong delay (Pioneer DJM-900NXS2 style, locked variant).
resample
Resamplers for variable-speed playback and vinyl scratching.
reverb
Reverb Beat FX: Freeverb algorithm wrapped with DJM-style depth + RT60 control.
roll_fx
Beat FX: Roll, Slip Roll, Rev Roll, Helix.
smoother
One-pole lowpass parameter smoother.
svf
Topology Preserving Transform (TPT) State Variable Filter.

Constants§

CHANNELS
Channel count for every frame in this crate. Stereo, fixed — see the crate-level docs for why.