NEON DJ’s entire sound engine is built on the Web Audio API — there are no third-party audio libraries loaded at startup. Every oscillator, filter, delay, convolution reverb, and limiter is a native browser node. This document catalogues every node type in use, where it appears, and what parameters are configured.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/kepabilbao67-bot/musicplayer2/llms.txt
Use this file to discover all available pages before exploring further.
Browsers enforce an autoplay policy: an
AudioContext created before a user gesture starts in the "suspended" state and produces no audio. NEON DJ defers AudioContext creation to the first interactive event and also calls AC().resume() at the start of every handler that could trigger sound. If you integrate NEON DJ’s patterns into another project, always ensure user interaction has occurred before calling audio-producing code.Node Reference Table
| Node Type | Where Used | Key Parameters |
|---|---|---|
AudioContext | Global singleton via AC() | sampleRate (device default, typically 44100 Hz) |
OfflineAudioContext | generateTrack() — pre-renders all genre tracks | 2 channels, 44100 Hz, length = bars × 16 × stepDur × sampleRate |
AudioBufferSourceNode | Deck playback, grain playback (scratch), all synth functions | playbackRate, loop, loopStart, loopEnd |
BiquadFilterNode | EQ (3 per deck), per-deck filter, snare HP, hat HP, bass LP, lead (none), chord LP, wobble LP, FX noise BP | Various — see detail below |
GainNode | Deck volume, crossfader, delay send, reverb send, master gain, flanger wet, echo wet, all synth envelopes | gain AudioParam |
DynamicsCompressorNode | Master limiter | threshold −3 dB, knee 0, ratio 20, attack 3 ms, release 250 ms |
ConvolverNode | Per-deck reverb | Synthesised 1.8 s impulse response (exponentially decaying noise) |
DelayNode | Per-deck echo (up to 2.0 s max), master echo (1.0 s max), master flanger (0.05 s max) | delayTime AudioParam |
OscillatorNode | All synth functions (kick, bass, lead, chord, wobble, FX riser, airhorn, impact, zap), flanger LFO | type, frequency AudioParam |
AnalyserNode | Per-deck VU meter (time-domain), master spectrum display (frequency-domain) | fftSize 256 (deck), 512 (master); smoothingTimeConstant 0.8 (master) |
WaveShaperNode | synthChord() — guitar power-chord distortion | curve (custom soft-clip), oversample "2x" |
ScriptProcessorNode | Recording — captures PCM from master output | Buffer size 4096, 2 input channels, 2 output channels |
Node Details
AudioContext / webkitAudioContext
AC() helper is the single access point to the audio context. All other code calls AC() rather than accessing audioCtx directly, ensuring the context is only created once and only after a user gesture.
OfflineAudioContext
OfflineAudioContext renders audio faster than real-time without sending it to the speakers. NEON DJ uses it inside generateTrack() to pre-render all genre tracks during the loading screen. The result is a standard AudioBuffer stored in DEMO_BUFFERS[key].
AudioBufferSourceNode
A new AudioBufferSourceNode is created by startSource() every time a deck starts playing, because source nodes can only be started once:
playGrain()) and for every note scheduled inside generateTrack().
BiquadFilterNode
Used in many different roles across the codebase:
- EQ (per deck)
- Filter sweep (per deck)
- Synth instruments
- FX one-shots
Three filters chained in series, constructed in
buildGraph():DynamicsCompressorNode
The master limiter sits between masterGain and ctx.destination:
ConvolverNode
Each deck has its own ConvolverNode for reverb. The impulse response is synthesised once and shared via getReverbIR():
Math.pow(1 - i/len, 2.5)) gives a smooth room tail without the harsh flutter of linear decay.
AnalyserNode
Two separate analysers are in use:
- Per-deck:
fftSize = 256, reads time-domain data (getByteTimeDomainData) for the 14-segment VU meter display. - Master spectrum:
fftSize = 512,smoothingTimeConstant = 0.8, reads frequency-domain data (getByteFrequencyData) for the spectrum canvas at the top of the page. Connected aftermasterLimiterviafinalNode().
WaveShaperNode
Used only in synthChord() to add guitar-style power-chord distortion:
ScriptProcessorNode
The recording system uses ScriptProcessorNode (the legacy PCM capture API) to collect raw stereo float samples from the master output:
encodeWAV(), or to MP3 by encodeMP3() if the lamejs library can be loaded dynamically from a CDN. ScriptProcessorNode is deprecated in favour of AudioWorkletNode, but remains broadly supported and avoids the complexity of loading a worklet module in a single-file context.