Skip to content

Plugin: Mixer

MixerPlugin (id 'mixer') is a master gain and stereo-pan stage, inserted as the last effect in Audio Graph’s chain, gain then panner then destination, so it always acts on the fully-processed signal from every other effect.

Options

OptionTypeDefaultPurpose
gainnumber (dB)0Initial master gain.
pannumber (-1..1)0Initial stereo pan.
persistKeystringStorage key. Omit to disable persistence.
maxGainDbnumber24Clamp ceiling (and floor, negated) for gain().
smoothingTimeConstantSecondsnumber0.02Ramp time for gain/pan changes.

Events

gain:changed ({ gain }), pan:changed ({ pan }), mute:changed ({ muted }), saved.

Rules & restrictions

  • static requires = [AudioGraphPlugin] — same missing-dep guard as every other effect in the chain.
  • gain() clamps to ±maxGainDb; pan() clamps to [-1, 1]. Out-of-range calls don’t throw, they saturate.
  • Ordering is fixed: this plugin is meant to be the last effect. Inserting your own effect after it defeats the “acts on the final mix” guarantee the plugin is built around.

How to extend it

TypeScript
import nmplayer from '@nomercy-entertainment/nomercy-video-player'; // nomercy-music-player's factory works identically
import { AudioGraphPlugin, MixerPlugin } from '@nomercy-entertainment/nomercy-player-core';

const player = nmplayer('player');

player.addPlugin(AudioGraphPlugin);
player.addPlugin(MixerPlugin, { persistKey: 'my-app-mix' });
await player.ready();

const mixer = player.getPlugin(MixerPlugin);
mixer!.gain(-3); // -3 dB
mixer!.pan(-0.2); // slightly left
mixer!.muted(true);

Next steps