Three.js Virtual DJ Mixer (Two Decks, Crossfader, Filters)
A 3D DJ console in Three.js with two generated Web Audio loops on spinning turntables, an equal-power crossfader, per-channel volume and low-pass filters, VU meters, tempo control and beat sync.
Key topics: dj mixer, web audio mixer, crossfader, turntable, three.js music, audio filter
Game Over
What this code does
- Routing: each deck's voices go to their own bus (gain → low-pass BiquadFilter) feeding the master compressor and analyser.
- Equal-Power Crossfade: gains cos(x·π/2) and sin(x·π/2) keep perceived loudness constant through the blend.
- Filters: a resonant low-pass sweep from 20 kHz to 200 Hz is the classic DJ transition, removing highs before swapping basslines.
- Tempo & Sync: each deck's sequencer has its own BPM, and Sync copies A's tempo to B and realigns both bars.
- Visuals: platters spin at 33⅓ RPM scaled by tempo, and the faders, filter knobs and VU meters mirror the GUI.
- Controls: crossfader, plus play, volume, filter and tempo per deck, and sync.
Related Demos
Continue Learning
JavaScript Implementation
// Two decks → per-channel gain + lowpass → master; equal-power crossfade keeps loudness constant
const deckA = ctx.createGain(), deckB = ctx.createGain()
const filterA = ctx.createBiquadFilter(); filterA.type = 'lowpass'
deckA.connect(filterA).connect(master); deckB.connect(master)
function setCrossfade (x) { // 0 = all A, 1 = all B
deckA.gain.value = Math.cos(x * Math.PI / 2)
deckB.gain.value = Math.sin(x * Math.PI / 2)
}
platterA.rotation.y -= dt * (33.33 / 60) * 2 * Math.PI * (bpmA / originalBpmA) // pitch-matched spin