Plugin: Audio Graph
AudioGraphPlugin (id 'audio-graph') owns the Web Audio signal chain: it creates or reuses the player’s AudioContext, mounts a MediaElementAudioSourceNode from the backend, and wires source → destination. Every other audio-processing plugin in the kit builds on this same chain rather than creating its own, though not identically: the equalizer and mixer insert themselves into the serial chain via insertEffect() / pre() / post(), the spectrum plugin parallel-taps the shared AnalyserNode instead of joining the serial path, and the visualization plugin depends only on canvas and spectrum, it never touches AudioGraphPlugin directly.
Options
| Option | Type | Default | Purpose |
|---|---|---|---|
latencyHint | AudioContextLatencyCategory | 'playback' | Forwarded to the AudioContext constructor. |
fftSize | 256 | 512 | ... | 16384 | 2048 | Analyser node size for plugins that read frequency/waveform data. |
smoothing | number (0-1) | 0.8 | Analyser smoothing time constant. |
Events
context:ready ({ sampleRate }), context:closed, chain:rebuilt, unsupported ({ reason }).
Rules & restrictions
- Register this plugin first. Every other audio plugin declares
static requires = [AudioGraphPlugin]and throwscore:plugin/missing-depat registration if it isn’t present. - Browser autoplay policy: the
AudioContextstarts'suspended'and is resumed only on the firstplayevent, so it must fire during or right after a user gesture. There’s no workaround, the browser enforces this regardless of what the kit does. - Throws a
BrowserPolicyErrorand emitsunsupportedwhenAudioContextis unavailable in the runtime (rare, but true for some embedded WebViews). outputNode()throws aPluginErrorif called beforeuse()has run.
How to extend it
Effects insert themselves via insertEffect(node, position?) (or the pre(node) / post(node) shorthands): the plugin owns node ordering so two independent effect plugins don’t have to coordinate insertion points with each other.
import nmplayer from '@nomercy-entertainment/nomercy-video-player'; // nomercy-music-player's factory works identically
import { AudioGraphPlugin } from '@nomercy-entertainment/nomercy-player-core';
const player = nmplayer('player');
player.addPlugin(AudioGraphPlugin, { fftSize: 4096 });
await player.ready();
const graph = player.getPlugin(AudioGraphPlugin);
const gain = graph!.context().createGain();
graph!.insertEffect(gain, 'post'); // spliced in after the source, before destination
Next steps
- Plugin: Equalizer: the first of the chain’s built-in effects.