worklet
Loading an AudioWorklet processor from @audio-ui/engine: its source into a context from a blob, once per context, false where worklets cannot run.
pnpm add @audio-ui/engine
import { loadWorklet } from "@audio-ui/engine/worklet";| Used by | clip-player, recording |
|---|
| Export | Kind | What it is |
|---|---|---|
loadWorklet | function | Loads the source of an AudioWorklet processor into a context, from a blob, so there is no file to serve. |
Usage
Loads the source of an AudioWorklet processor into a context, from a blob, so there is no file to serve. A source loads once per context: every later call gets the same promise.
import { loadWorklet } from "@audio-ui/engine/worklet";
if (await loadWorklet(ctx, MY_PROCESSOR_SOURCE)) {
const node = new AudioWorkletNode(ctx, "my-processor");
}It resolves to false, and never rejects, where the worklet cannot run: a context without worklets (a page without a secure origin) or a module that failed to load, so an engine plays without it rather than throwing. Every engine that runs a worklet loads it this way; createWorkletStage does it for you.