mwg API
    Preparing search index...

    Interface AudioCoreHostOptions

    interface AudioCoreHostOptions {
        blockFrames?: number;
        factory?: (sampleRate: number) => MidiSynth;
        factorySource?: string;
        mode?: "auto" | "worker" | "inline";
        prefetch?: boolean;
        queueSeconds?: number;
        sampleRate: number;
    }

    Hierarchy (View Summary)

    Index
    blockFrames?: number

    frames per render request; 1024 when omitted

    factory?: (sampleRate: number) => MidiSynth

    Builds the core for a sample rate. It is shipped to the worker as text, so it must be self-contained: no closures, no imports, everything it needs inside its own body.

    factorySource?: string

    Instead of factory: the text of a JavaScript expression that evaluates to the factory, for a core that cannot be self-contained because it has imports. Bundle the core into one classic script (an IIFE, with a bundler such as esbuild) whose last expression is the factory, e.g. (() => { ...bundled code...; return (rate) => new Core(rate); })(), and pass that text.

    mode?: "auto" | "worker" | "inline"

    'auto' tries a worker and falls back to the main thread; 'inline' never uses one; 'worker' fails instead of falling back. 'auto' when omitted

    prefetch?: boolean

    whether the host renders ahead as soon as it is made (true when omitted). Turn it off when a piece is about to be started with start: a core that has already rendered a second of silence is not in the state of a fresh one (a modelled instrument's noise generator keeps its place through reset), so the piece would sound slightly different from a direct render.

    queueSeconds?: number

    seconds of rendered audio kept ahead of the playhead; 0.3 when omitted, which is also the latency of a message sent now

    sampleRate: number