import { Size } from "../../models/rendering"; import { SpectrogramOptions } from "../../components/spectrogram/spectrogramOptions"; import { AudioInformation } from "./audioInformation"; export declare class AudioHelper { private readonly spectrogramWorker; private readonly state; private readonly sampleBuffer; private cachedResponse; private cachedAudioInformation; private offscreenCanvas; private generationData; private segmentSize; private generation; constructor(); get canvasTransferred(): boolean; connect(src: string, canvas: HTMLCanvasElement, options: SpectrogramOptions): Promise>; changeSource(src: string, options: SpectrogramOptions): Promise; regenerateSpectrogram(options: SpectrogramOptions): Promise; resizeCanvas(size: Size): void; /** * Gracefully stop any in-flight processing and free underlying resources. * - Aborts the current render generation and waits for the worker to become idle * - Terminates the spectrogram worker */ destroy(): Promise; private abort; /** * Internal render function. Does not check if we need to abort. * @param options the spectrogram options * @param generation the generation number * @param src if provided fetches the audio at the supplied source, otherwise clones a buffer of the last response */ private render; private createAudioInformation; private fetchAudio; private cachedBuffer; /** * Creates and prepares the audio context, but does NOT start rendering. * Returns a callback to start rendering, or undefined if setup failed. * This separation allows the caller to ensure the worker is ready before * the OfflineAudioContext begins pumping data through the processor. */ private createAudioContext; private setupWorker; private setupProcessor; private clearCanvas; private regenerateWorker; }