getContext

Returns the shared AudioContext, creating it on first call. All @web-kits/audio functions route through this single context.

import { getContext } from "@web-kits/audio";

const ctx = getContext();

Signature

function getContext(options?: ContextOptions): AudioContext;

ContextOptions

Configure the context on first creation. Options are ignored on subsequent calls.

PropertyTypeDescription
latencyHintstring"interactive", "balanced", "playback"
sampleRatenumberOutput sample rate

dispose

Close the shared context and release resources. A fresh context is created on the next getContext() call.

import { dispose } from "@web-kits/audio";

dispose();