How this random music generator works
Every track starts from a seed — any piece of text. For each beat of the track, the generator computes a SHA-256 hash of the seed plus the beat number. A SHA-256 hash is 32 bytes of unpredictable data, and the generator turns those bytes into music:
- Melody: each beat has four sixteenth-note steps. Every step reads one byte: the first hex digit picks one of 16 notes from the chosen scale, the second hex digit decides whether the note plays and how loudly.
- Harmony: at the start of each bar another byte chooses a chord root. A soft bass note and a pad chord are built on it, so the melody always has a footing.
- Drums (optional): a kick on beats 1 and 3, a clap on 2 and 4, and hi-hats on the steps where the hash says so.
Because the notes always come from one scale, random bytes never produce wrong notes — the pentatonic scales in particular contain no clashing intervals at all. Because SHA-256 is deterministic, the same seed and settings always give the same track, so you can come back to a melody you liked just by typing its seed again.
Downloading a track
Pick a track length and a file quality, then press Download WAV. The track is rendered offline in your browser, faster than real time, and saved as an uncompressed 16-bit WAV file. The file contains the same track you hear in the player for the same seed and settings, with a short fade-out at the end. Approximate file sizes per minute:
- 44.1 kHz stereo: about 10.1 MB per minute
- 44.1 kHz mono: about 5.0 MB per minute
- 22 kHz mono: about 2.5 MB per minute
Choosing a sound
- Minor pentatonic at 70–90 BPM with low density is calm and works well as background music for reading or focus.
- Major pentatonic sounds bright and playful.
- Dorian has seven notes per octave, so melodies wander more and sound jazzier.
- Hirajoshi gives an East Asian colour with its half-step intervals.
- Turn on drums and raise the tempo above 110 BPM for a more upbeat groove.
Technical Details
All sound is synthesised with the Web Audio API — no samples or recordings are used. Melody notes are triangle-wave plucks with a closing low-pass filter, panned across the stereo field by pitch and sent into a tempo-synced echo. Notes are scheduled ahead on the audio clock rather than with JavaScript timers, so the rhythm stays steady. Hashes are computed with the browser's built-in Web Crypto API, and everything runs locally: nothing is uploaded.
Keyboard Shortcuts
- Spacebar: Play/Pause
- N: New random track
- R: Toggle repeat