Fully tears down the current track and releases owned Web Audio resources.
After disposal, state resets to its defaults.
Maps a volume reading in dB to a UI-friendly percentage.
The mapping assumes a typical display range of [-40, 20] dB.
Volume in dB.
Percentage in [0, 100].
Wires a file input to processAudio().
File input element that provides audio files.
Cleanup function that removes the event listener.
Pauses playback while keeping the current playback position.
Starts/resumes playback for the currently loaded track.
If playback had previously reached the end, this restarts from the beginning.
Loads an audio file, constructs the Web Audio graph, and begins playback/analysis.
If an existing track is loaded, it is torn down first.
AnalyserNode with fftSize = 2048.Audio file selected by the user.
Stops playback and resets the playback position to the beginning.
This clears transient analysis state but keeps the AudioContext alive so that subsequent
play() calls can resume without rebuilding the entire graph.
Subscribes to state updates.
The listener is invoked immediately with the current state, then again on each subsequent state patch.
Unsubscribe function.
Audio processing/analysis engine.
Ownership:
AudioContextand nodes it creates.requestAnimationFrame).Thread model: this code runs on the main JS thread; Web Audio processing occurs on the browser's internal audio thread and is sampled into JS on each analysis tick.