pitch-shift-buffer-source
v2.1.0
Published
A pitch-shifting AudioBufferSourceNode built with Rubber Band
Downloads
468
Maintainers
Readme
psbs
A pitch shifting AudioBufferSourceNode built with Rubber Band
This should be a drop in replacement of AudioBufferSourceNode with a few new AudioParam
transpose— pitch in semitones, independent of speeddetune— pitch in cents, also independent of speedloopFade— crossfade across the loop seam, in seconds
playbackRate changes speed only. start(when, offset, duration), stop(when)
and the ended event work as usual.
Usage
import { PitchShiftBufferSource } from "pitch-shift-buffer-source"
const ctx = new AudioContext();
await PitchShiftBufferSource.init(ctx);
// then construct synchronously, just like AudioBufferSourceNode
const source = new PitchShiftBufferSource(ctx);
const buf = await ctx.decodeAudioData(await (await fetch('audio.wav')).arrayBuffer());
source.buffer = buf;
source.transpose.value = 4; // up a major third, speed unchanged
source.connect(ctx.destination);
source.start();Pick the Rubber Band algorithm at construction time:
const source = new PitchShiftBufferSource(ctx, { engine: 'finer', formant: 'preserved' });Options (each fixed at construction): 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.
