A groovebox that writes its own house and techno. Every bar it tries a few hundred small edits to one part, keeps the best, and moves on when nothing beats it.
Press play to hear how this take was found.
Best on headphones or speakers with some bass. On an iPhone, switch silent mode off. Space plays and pauses, N rolls a new take.
The bar playing now
Sixteen steps, counted 1 e & a. Taller means louder. Click a step to change it; you hear the edit from the next bar.
ghost normal accent added by a fill
The whole performance
First the search, one part at a time, then the finished track. Click anywhere to jump there at the next bar line.
Rules
Each rule scores the pattern from 0 to 100%. The fit is their weighted average; the number after the × is the weight.
The search
Each dot is a pattern the search tried in that bar. The line is the best so far, which is the one you hear.
Show as a table
Key and chords
chord bass lead in the scale
Where each instrument sits
Before the search, the page plays each instrument alone and measures how its energy is spread over ten octave bands. The mix rules use these figures.
How it works
Roll a take. The take number seeds every random choice: style, tempo, key, scale, the sound of each synth, and targets such as how many hats to play per bar. The same number always gives the same track. Pin the style, tempo, key or scale under the screen and the rest still rolls.
Measure the sounds. Each instrument is rendered on its own, silently, and its spectrum is measured.
Search one part at a time. A part starts as a random scatter of roughly the right number of notes, which is why its first bar sounds rough. Every bar, the page scores every pattern that is one edit away: a note added, removed, moved, made louder or softer, raised or lowered. It also tries a few random double edits. Then it takes the best one. When no edit helps, it shakes the pattern three times and climbs again. If that fails too, the part locks and the next one starts on top of it.
Mix pass. With all eight parts in place, five of them are searched once more with extra rules: leave other instruments their frequency bands, keep busy steps from getting crowded, and let the lead answer the chords.
Arrange. The locked patterns are laid out as a track: intro, groove, breakdown, build, drop, and out again. Fills close every four and eight bars. Filters sweep, risers climb, and there is one beat of silence before each drop.
The search itself takes about a tenth of a second, so it is worked out the moment a take is rolled and then performed at the speed of the music. That is why you can jump around in it.
Why takes differ. The targets change with every take, and many patterns tie for the best score. Why they stay musical. Every note comes from one scale, the kick is tuned to the key, and each rule encodes something producers do or listeners have been shown to prefer.
Limits. The rule weights are set by hand, not learned from data. The rules simplify the research they cite. Timing offsets stay under 12 milliseconds, because larger ones lowered groove ratings in listening tests (Davies et al. 2013). Every sound is synthesised in your browser; there are no samples and no mastering engineer, so it will not match a released record.
Sources
Butler 2006. Mark J. Butler, Unlocking the Groove: Rhythm, Meter, and Musical Design in Electronic Dance Music. Indiana University Press. How house and techno build tracks from interlocking loops.
Witek et al. 2014. Syncopation, Body-Movement and Pleasure in Groove Music. PLOS ONE 9(4). A medium amount of syncopation drew the strongest urge to move. Paper
Toussaint 2005. Godfried Toussaint, The Euclidean Algorithm Generates Traditional Musical Rhythms. BRIDGES conference. Spreading hits as evenly as possible reproduces rhythms from many traditions. PDF
Longuet-Higgins & Lee 1984. The Rhythmic Interpretation of Monophonic Music. Music Perception 1(4). The syncopation count used here. Paper
Lerdahl & Jackendoff 1983. A Generative Theory of Tonal Music. MIT Press. The grid of strong and weak beats.
Krumhansl & Kessler 1982. Tracing the Dynamic Changes in Perceived Tonal Organization in a Spatial Representation of Musical Keys. Psychological Review 89(4). Listeners hear the home note and its chord as the most stable. Paper
de Clercq & Temperley 2011. A Corpus Analysis of Rock Harmony. Popular Music 30(1). Which chord-to-chord moves are common in popular music. Paper
Tymoczko 2011. Dmitri Tymoczko, A Geometry of Music. Oxford University Press. Good chord changes move each voice a short distance.
Huron 2001. David Huron, Tone and Voice: A Derivation of the Rules of Voice-Leading from Perceptual Principles. Music Perception 19(1). Small steps keep a melody heard as one line. Paper
Huron 1996. David Huron, The Melodic Arch in Western Folksongs. Computing in Musicology 10. Phrases tend to rise and then fall.
von Hippel & Huron 2000. Why Do Skips Precede Reversals? The Effect of Tessitura on Melodic Structure. Music Perception 18(1). After a leap, melodies tend to head back toward the middle of their range. Paper
Plomp & Levelt 1965. Tonal Consonance and Critical Bandwidth. Journal of the Acoustical Society of America 38(4). Two tones close in pitch sound rough together. Paper
Caplin 1998. William E. Caplin, Classical Form. Oxford University Press. The two-part phrase in which the first half ends open and the second half closes.
Moore 2012. Brian C. J. Moore, An Introduction to the Psychology of Hearing, 6th edition. How one sound hides another that shares its frequency band.
Hafezi & Reiss 2015. Autonomous Multitrack Equalization Based on Masking Reduction. Journal of the Audio Engineering Society 63(5). Measuring how much the parts of a mix cover each other. Paper
Davies et al. 2013. The Effect of Microtiming Deviations on the Perception of Groove in Short Rhythms. Music Perception 30(5). Paper
Solberg & Dibben 2019. Peak Experiences with Electronic Dance Music. Music Perception 36(4). How listeners respond to the breakdown, build-up and drop. Paper
Wilson 2013. Chris Wilson, A Tale of Two Clocks. The scheduling method that keeps the beat steady in a browser. Article