Shows audio frequency spectrum
[heading: "Description"]Draws vertical bars representing the frequency spectrum of the currently playing audio. Uses the Web Audio API to analyse the game audio element and render the data each frame.
[heading: "Key Features"] [list] * Real-time frequency spectrum bars * Connects to game audio source through Web Audio API * Graceful fallback when audio analysis is unsupported [/list] [heading: "Constructor"] [table header] [ Parameter | Type | Description ] [ scene | Object | The Phaser game state scene ] [ x | number | Horizontal position ] [ y | number | Vertical position ] [ width | number | Display width in pixels ] [ height | number | Display height in pixels ] [/table] [heading: "Properties"] [table header] [ Property | Type | Description ] [ audioContext | AudioContext|null | Web Audio API context for analysis ] [ analyser | AnalyserNode|null | Analyser node providing frequency data ] [ dataArray | Uint8Array|null | Buffer holding raw frequency data ] [ bufferLength | number | Length of the frequency data buffer ] [ bars | Array | Sprites or metadata for drawn bars ] [ active | boolean | Whether the visualizer is running and drawing ] [/table] [heading: "Methods"] [table header] [ Method | Parameters | Description ] [ setupAudioAnalysis | () | Creates the Web Audio API context and analyser, connecting it to the scene's audio element. ] [ update | () | Fetches frequency data and redraws the spectrum bars each frame. ] [ destroy | () | Frees the graphics and closes the audio context. ] [/table] [heading: "Example Usage (Modding)"] [codeblock javascript] // Modding usage example const audioViz = new AudioVisualizer(scene, 0, 0, 200, 50); function update() { audioViz.update(); } [/codeblock] [footer: "© Retora 2026"]