@soundtouchjs/audio-worklet
Version:
AudioWorklet implementation of the SoundTouchJS library
71 lines • 2.26 kB
TypeScript
import type { RateTransposerInterpolationStrategy, SampleBufferType, StretchParameters } from '@soundtouchjs/core';
/**
* Options for `processOffline`.
*
* @remarks
* All audio transform parameters are optional and default to their neutral values
* (`pitch: 1.0`, `pitchSemitones: 0`, `playbackRate: 1.0`).
*/
export interface ProcessOfflineOptions {
/**
* The source audio buffer to process.
*/
input: AudioBuffer;
/**
* URL or path to the SoundTouch processor script, passed to `SoundTouchNode.register`.
*/
processorUrl: string | URL;
/**
* Pitch multiplier (1.0 = original pitch).
* @defaultValue 1.0
*/
pitch?: number;
/**
* Pitch shift in semitones, combined with `pitch`.
* @defaultValue 0
*/
pitchSemitones?: number;
/**
* Playback rate multiplier. Output length is scaled by `1 / playbackRate`.
* @defaultValue 1.0
*/
playbackRate?: number;
/**
* Interpolation strategy to use in the rate transposer.
*/
interpolationStrategy?: RateTransposerInterpolationStrategy;
/**
* WSOLA timing parameters to apply to the stretch stage.
*/
stretchParameters?: StretchParameters;
/**
* Internal sample buffer strategy.
*/
sampleBufferType?: SampleBufferType;
}
/**
* Renders audio through SoundTouch processing in an `OfflineAudioContext`.
*
* @remarks
* Creates an `OfflineAudioContext`, registers the processor module, builds the
* audio graph, applies all transform parameters, and returns the rendered
* `AudioBuffer`. The output length is estimated as
* `ceil(input.length / playbackRate)` to account for tempo changes.
*
* @param options Processing options including the input buffer and processor URL.
* @returns A Promise that resolves to the processed `AudioBuffer`.
*
* @example
* ```ts
* import { processOffline } from '@soundtouchjs/audio-worklet';
*
* const processed = await processOffline({
* input: audioBuffer,
* processorUrl: '/soundtouch-processor.js',
* pitchSemitones: -3,
* playbackRate: 1.2,
* });
* ```
*/
export declare function processOffline(options: ProcessOfflineOptions): Promise<AudioBuffer>;
//# sourceMappingURL=processOffline.d.ts.map