pnpm dlx shadcn@latest add @audio-ui/mixer-engine
import { createMixer } from "@/lib/mixer-engine";| Files | lib/mixer-engine.ts |
|---|---|
| Depends on | Nothing |
| npm | @audio-ui/engine |
| Used by | arrangement-engine |
| Export | Kind | What it is |
|---|---|---|
StripMix | interface | What a channel does with its sound. |
MixerTrack | interface | A track as the mixer plays it. |
MixerReturn | interface | A return track as the mixer plays it. |
MixerState | interface | |
ChainLink | interface | A device's sound path, as a chain links it. |
MixerStrip | interface | A channel of the mixer. |
Mixer | interface | |
createMixer | function | A mixer on the Web Audio API: a channel for each track and each return, and the main track, which goes to destination. |
Usage
mixer-engine is the mixing desk the engine plays through, usable on its own with sources of your own: a channel per track and per return (a track that names a group plays into that track's channel), each with a device chain (setChain), a volume, a pan, a switch and a solo, sends taken before or after the volume, pan and switch as each return asks, delay compensation from the latency each chain declares, a meter per channel, and the main track to the output. Nothing limits the main track, so a mix over full scale shows on the meters as it would in the file.
import { createMixer } from "@/lib/mixer-engine";
const mixer = createMixer(context);
mixer.update({
main: { gain: 1 },
returns: [{ gain: 1, id: "hall", latency: 0, on: true, pan: 0, pre: false, soloed: false }],
tracks: [{ gain: 0.8, id: "vox", latency: 288, on: true, pan: -0.2, sends: { hall: 0.3 }, soloed: false }],
});
source.connect(mixer.strip("vox")!.input);