audio

@audio/spatial-autopan1.2.0

Auto-panner

Auto-panner — LFO-driven stereo panning. Constant-power cos/sin law

Status
calibrated
Updated
Family
spatial, 12 packages under it
Plugin
autopan, effect, streaming, 2 parameters
Category
effects
Licence
MIT
Dependencies
none
Downloads
2,198 last month
Tests
66 in audiojs/spatial's CI, passed at 656b55c,

Listen

// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html
audio('/samples/music/modern/local-forecast.mp3').autopan()

// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html

Parameters

  • effect
  • streaming
rate
0.5 Hz
0.01 to 20 Hz
depth
1
0 to 1
import autoPanner from '@audio/spatial-autopan'

Collapses the input to mono (mid) each sample, then sweeps it between speakers with a sine LFO through the same constant-power cos/sin law as spatial-panner. Modifies left/right in place; sweep phase is carried on params._phase across calls.

autoPanner(left, right, { rate: 0.5, depth: 1 })   // both modified in place
Param Default
rate 0.5 Sweep speed, Hz (0.01–20)
depth 1 Sweep excursion, 0 (center) – 1 (full L/R)
fs 44100 Sample rate

For a host's block, sweep(st, left, right, rate, depth, moving) runs the same sweep with its state in a typed array, st = Float64Array.of(0, fs) (the phase, then the sample rate), so nothing is allocated: rate[0] is read once a block (a new rate bends the sweep, the phase going on from where it is), the depth is depth[i] for sample i while moving is 1, depth[0] throughout when it is 0. The audio.js manifest glides a host's ramp of depth sample by sample into it (its smoothing is 10 ms).

Use when: tremolo-style auto-pan; the sweep is continuous across blocks — reuse the same params object per instance.


Part of @audio/spatial — the spatial family umbrella.

MIT © audiojs