@purinton/resampler
Version:
A pure JavaScript, high-quality PCM audio resampler for Node.js. Converts s16le PCM between arbitrary sample rates and channel layouts (mono/stereo) with windowed-sinc filtering.
31 lines (28 loc) • 892 B
TypeScript
import { Transform } from 'stream';
/**
* Options for Resampler
*/
export interface ResamplerOptions {
/** Input sample rate (e.g. 48000) */
inRate: number;
/** Output sample rate (e.g. 24000) */
outRate: number;
/** Number of input channels (default: 1) */
inChannels?: number;
/** Number of output channels (default: 1) */
outChannels?: number;
/** Filter window size for the sinc interpolation (default: 8) */
filterWindow?: number;
/** Output volume multiplier (default: 1.0, range: 0.0–1.0+) */
volume?: number;
}
/**
* A high-quality PCM resampler implementing a windowed-sinc filter in pure JavaScript.
* Processes 16-bit signed little-endian samples (s16le).
*/
export class Resampler extends Transform {
/**
* @param options Configuration for sample-rate conversion, channel mapping, and volume
*/
constructor(options: ResamplerOptions);
}