@maruaudio/dsp/distortion/octave-divider is a monophonic waveform octave divider authored in Maru. A Schmitt detector arms when the input falls below −threshold and counts a crossing when it rises above +threshold; every division crossings it flips the polarity of a square wave, giving one (division 1) or two (division 2) octaves down. The square is scaled by an amplitude envelope of the input (5 ms attack, 100 ms release), then a 10 Hz DC blocker (@maru/filters-dc-block), a one-pole tone filter (@maru/filters-tone) and an output trim.
Parameters
configureOctaveDivider(state, division, threshold, toneHz, outputDb) uses clampFiniteWithFallback (@maru/math-range):
| Argument | Range | Fallback |
|---|---|---|
division | 2 when ≥ 1.5, otherwise 1 | |
threshold | 0.0001 to 0.1 hysteresis | 0.01 |
toneHz | 50 Hz to min(8 kHz, 0.45 × rate) | 1 kHz |
outputDb | −24 to 0 dB (@maru/math-decibels) | 0 dB |
Before the first configure, division is 1, threshold 0.01, tone 1 kHz and gain 1.
Lifecycle
initOctaveDivider(rate) (8 to 192 kHz, fallback 48 kHz) → configureOctaveDivider → octaveDividerTick → resetOctaveDivider, which clears the detector, counter, polarity, envelope and both filters. Ticks allocate nothing and do no I/O.
When to use it
A sub-octave under a single-note bass or guitar line, mixed with the dry signal outside this DSP node.
Limits
- Mono sample tick, wet only. There is no pitch estimator: chords, noise and complex crossings can mistrigger.
- Division changes need a caller fade or reset.
- Input is clamped to ±16 (non-finite → 0).