audio-file-decoder
Version:
Decode audio files using FFmpeg and WebAssembly
88 lines (85 loc) • 3.33 kB
TypeScript
// Generated by dts-bundle-generator v5.7.0
export interface DecodeAudioOptions {
multiChannel?: boolean;
}
/**
* Creates an AudioDecoder for the given audio file.
* Make sure to call dispose() when no longer needed to free its resources.
* @param {string} wasm - a path or inlined version to/of decode-audio.wasm
* @param {File | ArrayBuffer} fileOrBuffer - the audio file or buffer to process
* @returns Promise
*/
export declare function getAudioDecoder(wasm: string, fileOrBuffer: File | ArrayBuffer): Promise<AudioDecoder>;
/**
* A disposable class for decoding an audio file.
* Should only be instantiated with the getAudioDecoder() factory function.
* Make sure to call dispose() when no longer needed to free its resources.
*/
export declare class AudioDecoder {
private static MEMFS_PATH;
private _module;
private _sampleRate;
private _channelCount;
private _encoding;
private _duration;
constructor(m: any, data: ArrayBuffer);
get sampleRate(): number;
get channelCount(): number;
get encoding(): string;
get duration(): number;
/**
* Decodes audio from the currently loaded file.
* @param {number} start=0 - the timestamp in seconds to start decoding at.
* @param {number} duration=-1 - the length in seconds to decode, or -1 to decode until the end of the file.
* @param {DecodeAudioOptions} options={} - additional options for decoding.
* @returns Float32Array
*/
decodeAudioData(start?: number, duration?: number, options?: DecodeAudioOptions): Float32Array;
/**
* Disposes the AudioDecoder and frees its resources.
* Must be called after the decoder is no longer needed.
*/
dispose(): void;
}
/**
* Creates an AudioDecoderWorker for the given audio file.
* Make sure to call dispose() when no longer needed to free its resources.
* @param {string} wasm - a path or inlined version to/of decode-audio.wasm
* @param {File | ArrayBuffer} fileOrBuffer - the audio file or buffer to process
* @returns Promise
*/
export declare function getAudioDecoderWorker(wasm: string, fileOrBuffer: File | ArrayBuffer): Promise<AudioDecoderWorker>;
export interface AudioFileProperties {
sampleRate: number;
channelCount: number;
encoding: string;
duration: number;
}
/**
* A disposable class for decoding an audio file asynchronously.
* Should only be instantiated with the getAudioDecoderWorker() factory function.
* Make sure to call dispose() when no longer needed to free its resources.
*/
export declare class AudioDecoderWorker {
private _worker;
private _properties;
constructor(worker: Worker, properties: AudioFileProperties);
get sampleRate(): number;
get channelCount(): number;
get encoding(): string;
get duration(): number;
/**
* Decodes audio asynchronously from the currently loaded file.
* @param {number} start=0 - the timestamp in seconds to start decoding at.
* @param {number} duration=-1 - the length in seconds to decode, or -1 to decode until the end of the file.
* @param {DecodeAudioOptions} options={} - additional options for decoding.
* @returns Float32Array
*/
decodeAudioData(start?: number, duration?: number, options?: DecodeAudioOptions): Promise<Float32Array>;
/**
* Disposes the AudioDecoder and frees its resources.
* Must be called after the decoder is no longer needed.
*/
dispose(): void;
}
export {};