/** * OfflineProcessor - Process entire audio files with pitch shifting in a Web Worker * * This class provides an easy-to-use API for batch processing audio files with * pitch shifting and time stretching. All processing happens in a Web Worker to * keep the main thread responsive. * * Unlike the real-time BungeePitchShift class which uses AudioWorklet for live * audio, OfflineProcessor renders the entire audio offline which is much faster * but cannot be used for real-time playback. * * @example * ```typescript * const processor = new OfflineProcessor(); * * const processed = await processor.process(audioBuffer, { * pitch: 5, * speed: 1.2, * onProgress: (progress) => console.log(`${progress * 100}%`) * }); * * processor.dispose(); * ``` */ import type { OfflineProcessingOptions } from './types'; /** * Configuration options for OfflineProcessor */ export interface OfflineProcessorConfig { /** * Path or URL to the worker script * @default '/audio-processor.worker.bundle.js' */ workerPath?: string; /** * Path to AudioWorklet processor (passed to worker) * @default '/bungee-processor.js' */ workletPath?: string; /** * Path to WASM loader (passed to worker) * @default '/bungee-wasm.js' */ wasmPath?: string; /** * Path to WASM binary (passed to worker) * @default '/bungee-wasm.wasm' */ wasmBinaryPath?: string; /** * Maximum time to wait for operations (in milliseconds) * @default 300000 (5 minutes) */ timeout?: number; } /** * OfflineProcessor class for batch audio processing */ export declare class OfflineProcessor { private worker; private pendingRequests; private config; private isReady; private readyPromise; /** * Create a new OfflineProcessor instance * * @param config - Configuration options * * @example * ```typescript * const processor = new OfflineProcessor({ * workerPath: '/workers/audio-processor.worker.js', * workletPath: '/audio/bungee-processor.js' * }); * ``` */ constructor(config?: OfflineProcessorConfig); /** * Initialize the worker */ private initialize; /** * Handle messages from the worker */ private handleWorkerMessage; /** * Send a request to the worker and wait for response */ private sendRequest; /** * Process an audio buffer with pitch shifting and time stretching * * @param audioBuffer - The audio buffer to process * @param options - Processing options (pitch, speed, mix, etc.) * @returns Promise that resolves to the processed audio buffer * * @throws {Error} If processing fails or times out * * @example * ```typescript * const processed = await processor.process(audioBuffer, { * pitch: 5, // +5 semitones * speed: 1.2, // 20% faster * mix: 1.0, // 100% wet * onProgress: (progress) => { * console.log(`Progress: ${Math.round(progress * 100)}%`); * } * }); * ``` */ process(audioBuffer: AudioBuffer, options: OfflineProcessingOptions): Promise; /** * Process audio with a provided AudioContext for deserialization * * This is the preferred method as it uses the user's AudioContext * instead of creating a temporary one. * * @param audioBuffer - The audio buffer to process * @param audioContext - AudioContext for creating the result buffer * @param options - Processing options * @returns Promise that resolves to the processed audio buffer * * @example * ```typescript * const audioContext = new AudioContext(); * const processed = await processor.processWithContext( * audioBuffer, * audioContext, * { pitch: 5, speed: 1.0 } * ); * ``` */ processWithContext(audioBuffer: AudioBuffer, audioContext: BaseAudioContext, options: OfflineProcessingOptions): Promise; /** * Check if the processor is ready to accept requests * * @returns True if the worker is initialized and ready */ get ready(): boolean; /** * Wait for the processor to be ready * * @returns Promise that resolves when the processor is ready */ waitForReady(): Promise; /** * Dispose and clean up resources * * Call this when you're done using the processor. * After calling dispose(), this instance should not be used again. * * @example * ```typescript * processor.dispose(); * processor = null; * ``` */ dispose(): void; } //# sourceMappingURL=OfflineProcessor.d.ts.map