Skip to main content

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.

NEON DJ generates all its built-in music programmatically — no audio samples are loaded from disk. A suite of low-level synthesis functions creates each instrument sound by scheduling OscillatorNode, noise buffers, BiquadFilterNode, and GainNode objects with precise time-based envelopes. Every function accepts an AudioContext (either a live AudioContext or an OfflineAudioContext) and a destination node, making them usable both during offline track rendering and in real-time FX playback.

Utility

makeNoise

function makeNoise(ctx, seconds)
Creates a white noise AudioBuffer of the given duration by filling a single-channel buffer with uniformly distributed random samples in the range [−1, 1].
ctx
AudioContext | OfflineAudioContext
required
The audio context used to allocate the buffer. The buffer’s sample rate matches ctx.sampleRate.
seconds
number
required
Duration of the noise buffer in seconds. Drum functions typically pass 1.5 to have enough noise for any scheduled burst.
Returns an AudioBuffer. The same noise buffer is shared across all percussion voices in a single generateTrack() render.

Percussion Functions

synthKick

function synthKick(ctx, dest, t)
Synthesizes a kick drum using a sine OscillatorNode with a steep pitch envelope and a gain envelope.
ctx
AudioContext
required
The rendering context.
dest
AudioNode
required
Destination node (typically the track’s master gain or an offline context destination).
t
number
required
Start time in seconds (ctx.currentTime-relative for live playback, or absolute step offset for offline rendering).
The oscillator starts at 160 Hz and exponentially ramps down to 48 Hz over 0.13 s, producing the characteristic “thump”. Gain ramps from 1.0 to near-zero over 0.42 s. Total node lifetime: 0.45 s.

synthSnare

function synthSnare(ctx, noise, dest, t)
Synthesizes a snare drum by layering a highpass-filtered noise burst with a short triangle-wave sine body.
ctx
AudioContext
required
The rendering context.
noise
AudioBuffer
required
Pre-allocated white noise buffer (from makeNoise).
dest
AudioNode
required
Destination node.
t
number
required
Start time in seconds.
The noise component is highpass-filtered at 1400 Hz and decays over 0.18 s. The body is a triangle oscillator at 190 Hz, decaying over 0.1 s at volume 0.5. Both layers connect to dest independently.

synthClap

function synthClap(ctx, noise, dest, t)
Synthesizes a clap by firing three slightly offset noise bursts through a bandpass filter, simulating the smeared hand-clap transient.
ctx
AudioContext
required
The rendering context.
noise
AudioBuffer
required
Pre-allocated white noise buffer.
dest
AudioNode
required
Destination node.
t
number
required
Start time of the first burst. Subsequent bursts are scheduled at t + 0.012 and t + 0.024.
Each burst uses a bandpass filter at 1600 Hz (Q = 1.2) and decays from 0.5 to near-zero over 0.12 s.

synthHat

function synthHat(ctx, noise, dest, t, open)
Synthesizes a hi-hat by highpass-filtering a noise burst at 7500 Hz. The open parameter controls whether the hat is open (long decay) or closed (short decay).
ctx
AudioContext
required
The rendering context.
noise
AudioBuffer
required
Pre-allocated white noise buffer.
dest
AudioNode
required
Destination node.
t
number
required
Start time in seconds.
open
boolean
required
true for open hi-hat (0.28 s decay), false for closed hi-hat (0.045 s decay).
Peak gain is 0.32. The node stops at t + dur + 0.02 to allow a clean tail without early cutoff clicks.

Melodic Functions

synthBass

function synthBass(ctx, dest, t, freq, dur)
Synthesizes a bass note using a sawtooth oscillator through a resonant lowpass filter, with a punchy attack-decay gain envelope.
ctx
AudioContext
required
The rendering context.
dest
AudioNode
required
Destination node.
t
number
required
Start time in seconds.
freq
number
required
Fundamental frequency in Hz. Typically derived from midiToFreq(midiNote).
dur
number
required
Note duration in seconds. The gain envelope reaches peak at t + 0.012 then decays to near-zero at t + dur.
The lowpass filter is fixed at 520 Hz with Q = 6, giving the bass a slightly growling, sub-heavy character. Peak gain is 0.42. Oscillator stops at t + dur + 0.03.

synthLead

function synthLead(ctx, dest, t, freq, dur, type, vol)
Synthesizes a melodic lead note with a configurable oscillator waveform and short attack/release envelope.
ctx
AudioContext
required
The rendering context.
dest
AudioNode
required
Destination node.
t
number
required
Start time in seconds.
freq
number
required
Frequency in Hz.
dur
number
required
Note duration in seconds.
type
OscillatorType
default:"square"
Oscillator waveform type: "sine", "square", "sawtooth", or "triangle". Different genres use different types — synthwave arpeggios use "square", house pads use "sawtooth".
vol
number
default:"0.16"
Peak gain value. Typical range 0.05–0.12 when layering chords; higher for solo leads.
Attack is 10 ms (t + 0.01). The note decays from vol to near-zero at t + dur.

synthChord

function synthChord(ctx, dest, t, rootMidi, dur, vol, drive)
Synthesizes a distorted guitar power chord using three sawtooth oscillators (root, perfect fifth, octave) fed through a WaveShaperNode and a lowpass filter.
ctx
AudioContext
required
The rendering context.
dest
AudioNode
required
Destination node.
t
number
required
Start time in seconds.
rootMidi
number
required
MIDI note number of the chord root. The three voices are rootMidi, rootMidi + 7 (perfect fifth), and rootMidi + 12 (octave).
dur
number
required
Chord duration in seconds.
vol
number
default:"0.12"
Peak output gain after distortion and filtering.
drive
number
default:"18"
Distortion drive amount fed into makeDistCurve(k). Higher values produce heavier saturation. Rock Spanish uses 16, Heavy Metal uses 26.
The three oscillators feed a shared GainNode (pre, gain 0.3) → WaveShaperNode (soft-clip curve, oversample "2x") → BiquadFilterNode (lowpass, 3200 Hz) → output gain envelope.

synthWobble

function synthWobble(ctx, dest, t, freq, dur, lfoRate)
Synthesizes a dubstep-style wobble bass using a detuned sawtooth+square oscillator pair, a heavily resonant lowpass filter, and an LFO modulating the filter cutoff.
ctx
AudioContext
required
The rendering context.
dest
AudioNode
required
Destination node.
t
number
required
Start time in seconds.
freq
number
required
Fundamental frequency in Hz.
dur
number
required
Note duration in seconds.
lfoRate
number
default:"5"
LFO oscillation rate in Hz. The dubstep genre uses 5 Hz on beat 1 and 8 Hz on beat 3 for rhythmic variety.
The second oscillator is detuned by 0.5% (freq * 1.005) for a thick chorus effect. The lowpass filter sits at 600 Hz with Q = 9. The LFO depth is ±450 Hz, producing a dramatic cutoff sweep. Total node lifetime: t + dur + 0.03.

FX One-Shot Functions

FX functions trigger sounds in real time through the live AudioContext and master output. They do not accept time parameters — they fire immediately at ctx.currentTime.

fxRiser

function fxRiser()
A 2.2-second build-up effect combining a bandpass-filtered noise sweep and a sawtooth oscillator pitch sweep. The bandpass filter frequency ramps from 300 Hz to 9000 Hz; the oscillator sweeps from 200 Hz to 2000 Hz. Gain ramps from near-zero to 0.5 (noise) / 0.12 (oscillator) and fades out 150 ms after the sweep completes.

fxAirhorn

function fxAirhorn()
A 1.1-second airhorn sound made from four sawtooth oscillators tuned to a chord (B♭3 + a slightly detuned copy + F4 + slightly detuned copy), all passing through a lowpass filter at 3500 Hz. The oscillators pitch-slide upward by ~4% over 120 ms for the characteristic “push” feel.

fxImpact

function fxImpact()
A 1.6-second dramatic impact combining a low sine oscillator (220 Hz → 28 Hz pitch drop) and a lowpass-filtered noise burst (6000 Hz → 200 Hz filter sweep), both decaying together. Peak sine gain is 0.6; peak noise gain is 0.5.

fxZap

function fxZap()
A 0.4-second zap/laser sound: a square oscillator that pitch-drops from 1800 Hz to 120 Hz with a matching gain envelope (peak 0.2). Fast and attention-grabbing.

Master FX Functions

flangerThrow

function flangerThrow()
Triggers a momentary flanger sweep on the master output by ramping masterFlangerWet.gain:
  • 0 → 0.85 over 0.1 s (instant throw)
  • Holds at 0.85 until t + 2.6 s
  • 0.85 → 0 over the next 0.7 s (total duration: 3.3 s)
Any previously scheduled ramp values are cancelled with cancelScheduledValues before the new ramp is set.

echoThrow

function echoThrow()
Triggers a momentary echo effect on the master output by ramping masterEchoWet.gain:
  • 0 → 0.6 over 0.05 s
  • Holds at 0.6 until t + 2.0 s
  • 0.6 → 0 over the next 0.6 s (total duration: 2.6 s)
The underlying echo path uses a 0.34 s delay with 0.45 feedback gain, creating multiple audible repeats that trail off naturally.

brakeAll

function brakeAll()
Calls brake() on any deck that is currently playing. Each deck’s brake() method ramps source.playbackRate from its current value down to 0.001 over 0.7 s using linearRampToValueAtTime, then stops the source after 730 ms and leaves the deck paused at the braked position. This is the “tape stop” or vinyl brake effect.
All synth functions use exponentialRampToValueAtTime for gain envelopes rather than linearRampToValueAtTime. Exponential ramps sound perceptually smoother because human hearing perceives loudness on a logarithmic scale. The setValueAtTime call immediately before each ramp is required — Web Audio will ignore an exponential ramp if there is no preceding scheduled value for the parameter.

Build docs developers (and LLMs) love