@paramrig/audio-browser
Independent AudioWorklet players for @paramrig/audio, without React or editor UI.
npm install @paramrig/audio @paramrig/audio-browser
import { defaultPatch } from '@paramrig/audio'
import { createAudioPlayer } from '@paramrig/audio-browser'
const context = new AudioContext()
const player = createAudioPlayer({ context, destination: context.destination })
// Start from a user gesture in a secure browser context.
await player.start(defaultPatch())
player.setPatch(defaultPatch())
player.trigger()
player.stop()
player.destroy()
// Only the host may decide to close its context.
The player exposes start, setPatch, setGate, trigger, stop, getMeter, getError, isPlaying, subscribe and destroy. A subscription returns an unsubscribe function. start returns false on unavailable playback and records the error; onError can receive it. A destroyed player cannot restart.
The compiled processor is distributed with the package and referenced relative to its module. Bundlers must copy URL assets. audioWorkletUrl exposes the default location; supply workletUrl when your bundler or CSP requires another location. Serve the processor as JavaScript from an allowed origin.
Supply resolveWavetable for host resources. Each player and worklet processor maintains its own user table registry. Two players may use the same resource ID with different frames. The host owns its AudioContext and destination; destroying a player disconnects only that player’s nodes, closes its ports and releases its subscriptions.
Supported environment and dependencies
| Environment | Dependencies |
|---|---|
| Browser with AudioWorklet in a secure context | Audio and Core; no React |
Run the complete example
Copy the Browser audio example into a directory of its own. Its README lists the commands and resource setup. It imports only public packages; no repository aliases, editor sources or development dependencies from ParamRig are required.
Choose the boundary
The packages ship ESM JavaScript and TypeScript declarations. A sub-entry selects the code your bundler loads. A separate package changes what npm installs. The complete editor is part of the application; this SDK exposes its engine or controls.
Compare packages · Build a selective application distribution