timestretcher
v3.2.0
Published
Offline time-stretching and pitch-shifting with Rubber Band, returning an AudioBuffer
Maintainers
Readme
timestretcher
Offline time-stretching & pitch-shifting built with Rubber Band
Stretch or pitch-shift an AudioBuffer
offline — in a Worker, off the main and
audio threads — and get an AudioBuffer back. Play it through a plain
AudioBufferSourceNode
timeRatio— output duration ÷ input durationsemitones— pitch shift
Usage
import { Timestretcher } from "timestretcher"
await Timestretcher.init(); // load the wasm, spins up the worker
const buf = await ctx.decodeAudioData(await (await fetch('audio.wav')).arrayBuffer());
const out = await Timestretcher.timestretch(buf, { timeRatio: 1.5, semitones: 4 });
new AudioBufferSourceNode(ctx, { buffer: out }).start();Pick the Rubber Band algorithm:
Timestretcher.timestretch(buf, { engine: 'finer', formant: 'preserved' });Options: engine, formant, pitchMode, transients, detector, phase,
window, smoothing, channels.
The defaults work well enough for me.
Build
Needs the Emscripten SDK
npm run buildLicense
GPL-2.0-or-later as per rubberband. See LICENSE.
