Bar by Bar

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

    1. 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.
    2. Measure the sounds. Each instrument is rendered on its own, silently, and its spectrum is measured.
    3. 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.
    4. 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.
    5. 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