/** * AudioWorklet is only exposed in secure contexts (HTTPS or localhost). On a * plain-HTTP page this module runs the same spessasynth processor script on * the main thread instead, driven by a ScriptProcessorNode for live playback * and pumped by hand for offline rendering. * * The processor script is evaluated with stand-ins for the worklet globals it * touches (AudioWorkletProcessor, registerProcessor, sampleRate, currentTime); * it reads `currentTime` only once, at construction, and counts samples after * that, so a fixed value per evaluation is enough. */ export type FallbackWorkletNode = { readonly context: BaseAudioContext; readonly port: MessagePort; connect(destination: AudioNode, output?: number): void; disconnect(): void; /** Offline contexts only: renders the processor into `target` from its start. */ renderInto(target: AudioBuffer, onProgress?: (fraction: number) => void): Promise; }; export type WorkletNodeCreator = (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions) => AudioWorkletNode; /** * Chrome keeps the AudioWorkletNode constructor on insecure pages but leaves * `context.audioWorklet` undefined, so test the context itself. */ export declare function needsWorkletFallback(context: BaseAudioContext): boolean; /** * Loads the processor script and returns a node creator for * `new WorkletSynthesizer(context, { audioNodeCreators: { worklet } })`. * `nodes` receives each node created, so offline renders can be pumped. */ export declare function createFallbackWorkletCreator(workletUrl: string, context: BaseAudioContext, nodes?: FallbackWorkletNode[]): Promise;