@maruaudio/dsp/spectral/delay-pitch-shifter transposes general stereo audio with two sweeping delay taps per channel; it needs no pitch detector. The ratio is 2^(semitones / 12) and each channel's tap phase advances by (1 − ratio) / windowFrames per sample. A second tap reads half a cycle away, and the two are crossfaded with weights sin²(π × phase) and its complement. It reads caller-owned rings before writing, outputs wet only, and slews the ratio through a 30 ms one-pole.
Parameters
configureDelayPitchShifter(state, leftShift, rightShift, windowMs, delayMs, phaseDegrees, smooth); non-finite values take the fallback.
| Argument | Range as coded | Fallback | Unit |
|---|---|---|---|
leftShift, rightShift | −25 to +25 | 0 | semitones |
windowMs | 20 to 100 | 50 (the init window) | ms |
delayMs | 0 to 30, added to a 2-frame minimum tap | 0 | ms |
phaseDegrees | 0 to 180; offsets the right tap phase | 0 | degrees |
smooth | false jumps the ratios to their targets | flag |
Lifecycle
Outside realtime, initDelayPitchShifter(sampleRate) (rate clamped to 8 to 192 kHz, 48 kHz for a non-finite rate) and two caller-owned fractional delay rings, each holding window + offset + 2 frames. Then configureDelayPitchShifter → delayPitchShifterTick(state, ringLeft, ringRight, left, right) per frame, reading outLeft and outRight → resetDelayPitchShifter, which resets phases and snaps the ratios to their targets; the caller resets or clears the rings.
When to use it
Transposing chords, drums or other material a pitch detector cannot follow, and opposite detune between channels (algorithm inventory).
Limits
- Stereo frame tick; the state owns no storage. Non-finite inputs write 0.
- No fixed latency: taps sweep. At zero shift and reset phase the delay is
window/2 + offset(1202 frames for 50 ms at 48 kHz); the caller fades phase edits. - Wet only. A partial mix against the undelayed input can comb-filter.