useMixer
Mixer state with no audio attached: gain, mute, solo, pan and monitor per channel, plus a master.
$ pnpm dlx shadcn@latest add @audiocn/use-mixerUsage
const mixer = useMixer({
channels: [{ id: "mic" }, { id: "music", gainDb: -12 }],
persistKey: "my-app-mixer",
});
mixer.setGain("mic", -3);
mixer.setSolo("music", true, { exclusive: true });
mixer.isAudible("mic"); // false while music is soloeduseMixer only holds state. Connect it to sound with useWebAudioMixer, or read mixer.state and send it to your own engine.
Options
Prop
Type
A channel is { id, gainDb, muted, solo, pan, monitor }. pan runs from −1 to 1.
Returns
Prop
Type
mixerReducer and isChannelAudible are exported for use outside React.