Plugin: Spectrum
SpectrumPlugin (id 'spectrum') reads Audio Graph’s analyser node once per animation frame and produces a VisualizationFrame: frequency and waveform buffers (both byte and float), per-band energy (bass / mid / treble), and beat/BPM fields when a beat provider is registered. Visualization is the primary consumer, but any plugin can read frames directly.
Options
| Option | Type | Default | Purpose |
|---|---|---|---|
fftSize | 512 | 1024 | 2048 | 4096 | inherits Audio Graph’s analyser | Analysis resolution. |
smoothingTimeConstant | number | inherits Audio Graph’s analyser | Analyser smoothing. |
stereo | boolean | false | Allocate separate left/right analysers instead of one summed channel. |
frameRate | number | — | Reserved, currently unused. |
Events
frame ({ frame: VisualizationFrame; energy: { bass, mid, treble } }), opts:changed.
Rules & restrictions
static requires = [AudioGraphPlugin]— throwscore:plugin/missing-depwithout it.stereo: trueallocates two extraAnalyserNodes and four extra typed-array buffers per frame, only turn it on when a consumer actually needs per-channel data.- Synthetic mode (
syntheticMode(true)+pushFrame(frame)) exists for passive NoMercy Connect receivers that have no local audio stream to analyse: it bypasses theAnalyserNodeentirely and re-emits the last pushed frame verbatim.time/deltaMson a synthetic frame are not overridden by the canvas RAF clock the way a real-analysis frame’s are.
How to extend it
TypeScript
import nmplayer from '@nomercy-entertainment/nomercy-video-player'; // nomercy-music-player's factory works identically
import { AudioGraphPlugin, SpectrumPlugin } from '@nomercy-entertainment/nomercy-player-core';
const player = nmplayer('player');
player.addPlugin(AudioGraphPlugin);
player.addPlugin(SpectrumPlugin, { stereo: false });
await player.ready();
const spectrum = player.getPlugin(SpectrumPlugin);
console.log(spectrum!.bandEnergy(20, 250)); // energy in the bass range, right now
Next steps
- Plugin: Visualization: the base class that turns these frames into pixels.