@audio/shift-pvoc-lock
v1.0.2
Published
Peak-locked phase vocoder (Laroche-Dolson) pitch shift
Readme
@audio/shift-pvoc-lock

Peak-locked phase vocoder (Laroche-Dolson) pitch shift
npm install @audio/shift-pvoc-lockimport phaseLock from '@audio/shift-pvoc-lock'Laroche-Dolson peak-locked phase vocoder. Peaks scatter to shifted bins; non-peak bins lock their phase relative to the nearest peak, keeping the vertical phase relationship inside each sinusoidal lobe intact.
phaseLock(audio, { ratio: 1.5 })Preserves phase coherence around peaks, partial structure.
Destroys transients (still smeared, less than vocoder), formants.
| f0 err | THD% | alias | attack corr | formant dist | phase coh | shift | |-------:|-----:|------:|------------:|-------------:|----------:|------:| | 0.00 | 0.0 | 0.000 | 0.984 | 1.423 | 0.999 | 1.755 |
Use when: General music — the "try this first" phase vocoder.
Not for: Music with drums (use transient), voice (use formant).
Stream
let write = phaseLock({ ratio: 1.5 })
let out = write(inputBlock)
let tail = write() // flushphaseLock streams per-frame: each write(chunk) call renormalizes and emits audio as soon as a frame completes, and re-chunking the same input differently reproduces the batch output byte for byte.
Data
Input is a Float32Array (mono) or an array of Float32Array channels ([left, right, ...]) — anything else throws TypeError. ratio also accepts a function t => ratio (seconds from stream start) or a Float32Array breakpoint envelope (resampled across the input via ratioDuration, default the input's own duration) for time-varying pitch.
Part of @audio/shift — the shift family umbrella. This README is generated from the umbrella docs.
MIT © audiojs
