Three.js Audio Landscape (Synthwave Spectrum Terrain)

Fly over a synthwave terrain built from music in Three.js, where every new row of mountains is the current audio spectrum, mirrored into a valley road under a striped sun with a neon grid and bloom.

Key topics: audio landscape, synthwave, spectrum terrain, audio visualization, three.js bloom, web audio music

What this code does

- Terrain From Sound: about 30 times a second the log-spaced spectrum (40 Hz–12 kHz) becomes a new terrain row and older rows scroll away.
- Mirroring: low frequencies sit in the centre, leaving a flat road, and highs rise into mountains at the edges.
- Rendering: a vertex-coloured mesh and a wireframe copy share one geometry, with UnrealBloomPass for the neon glow.
- Music: an Am–F–C–G arpeggio, bass, pads and drums generated live with Web Audio oscillators and noise.
- Camera: a gentle bob on bass energy adds motion.
- Controls: scroll speed, peak height, mirror, neon grid and bloom.

Continue Learning

JavaScript Implementation

ES6+
// Audio landscape: every frame pushes a new row of spectrum heights into a scrolling grid
analyser.getFloatFrequencyData(db)
rows.copyWithin(COLS, 0, COLS * (ROWS - 1))             // move old rows back
for (let c = 0; c < COLS; c++) {
  const u = Math.abs(c / (COLS - 1) * 2 - 1)            // mirror: lows in the centre
  rows[c] = Math.max(0, (db[binFor(40 * Math.pow(300, u))] + 90) / 65) ** 2
}
rows.forEach((v, i) => positions.setY(i, v * 5))       // shared by a solid + wireframe mesh