PULSEDROP Open in browser Download GitHub 한국어

How it listens

How Pulsedrop hears a song

Milkdrop moves when the sound gets louder. Pulsedrop also tells the picture where the beat is, which beat of the bar this is, what part of the song is playing and how intense the music is.

The figures below are not drawings. They are what the app's analysis code (src/audio) produced for real songs. Two songs are used as examples. Mikael (Live) by Meaningful Stone is a shoegaze song that keeps one speed for 4:44. Illumination Theory by Dream Theater runs 22 minutes, changes speed and meter many times, and ends with thirty seconds of silence and a hidden track. Move the pointer over a figure to read values.

85%Beats it gets right. Beats within 0.07 s of where people tapped them, measured on 120 songs in ten genres.
91%Songs counted in the right meter. Whether a bar has three beats or four, on the same 120 songs.
1 msError in finding its place. When a song it has heard before plays again, how exactly it knows where in the song we are. 1 ms is a thousandth of a second.

How these were measured, and what it does not do well yet, is in part 10.

First, four words

If music terms are new to you, these four are enough to read the rest.

  • Beat: the spacing at which you tap your foot.
  • Tempo (BPM): how many beats come in a minute. At 120 BPM there is one every half second.
  • Bar: a group of beats counted together. Most pop is counted "one two three four", four beats to a bar.
  • Time signature: how the beats of a bar are written down. 4/4 has four beats, 3/4 has three, like a waltz. Some, such as 7/8, have beats of unequal length.

An illustration. Switch the time signature to see how beats and bars are counted. The beat LEDs in the app's control bar light up like this.

A song is also made of parts: intro, verse, chorus. This page calls them sections.

1. Milkdrop reacts to loudness

A Milkdrop preset is given three numbers at every moment: how much louder than usual the low (bass), middle (mid) and high (treb) sounds are. Presets are written to zoom or flash when the bass rises.

That works well when a kick drum stands alone. In a song full of guitars the bass level moves all the time, with or without a beat. And because the level has to rise before anything can react to it, the picture is always a little behind the sound.

Sixteen seconds of Mikael (Live), from 1:36. The gold line is the bass level a preset is given. Green vertical lines are the beats Pulsedrop found, white ones the first beat of each bar. From the bass level alone it is hard to tell where the beats are.

Pulsedrop passes these three numbers on at Milkdrop's own scale, because presets were written for them. On top of that it tells the picture where the beat is.

2. Who finds the beat

Two neural network models find the beats. They were published by Johannes Kepler University Linz, Austria, and learned from thousands of songs in which people had marked the beats. Both run on your own computer, with no server, and are about 9 MB each.

  • Beat This! looks at a whole song at once. It knows what comes before and after every moment, which makes it the more accurate one. It is used for files and for video export.
  • Beat This! Live takes the sound 0.02 s at a time and answers at once, without knowing what comes next. It is used for whatever the computer is playing: Spotify, a browser tab.

A model does not give a list of beats. Fifty times a second it gives two numbers: how likely this moment is a beat, and how likely it is the first beat of a bar. Choosing the speed, counting bars, finding sections and reading the mood from there is Pulsedrop's own work, described in parts 3 to 9.

3. Counting at the right speed

You can tap your foot slowly to a song, or twice as fast. Both fit the music. People settle on one without thinking; programs often pick the other. Count a slow song twice too fast and the picture races against the mood of the music.

Mikael (Live) is such a song. A listener taps about 72 times a minute, and the guitars strum in between throughout. Measured by how hard each sound starts, the points between the beats are nearly as strong as the beats. By that measure alone, 144 looks like the beat.

Measured over the whole song. Left: how hard sounds start. Between the beats it is – of what it is on them, nearly the same. Right: the model's "how likely is this a beat". Between the beats it is only – of the value on them. The model clearly chose the slow count.

So Pulsedrop leaves the choice of speed to the model. The live model, though, decides without knowing what follows, and now and then goes to double speed for a few seconds. Pulsedrop's beat clock follows such a change only when it lasts: about 15 s before it speeds up, about 6 s before it slows down.

The same song heard live, ten seconds per cell. Top: the beats the live model marked, counted as they are. Bottom: after Pulsedrop's beat clock.

4. Not being late for the beat

Analysing sound takes time. Some sound has to be collected before it can be measured, the model needs a moment to answer, and the result is drawn a frame later. Together that is 0.05 to 0.08 s. A picture that draws what was just measured flashes that much after the beat. It sounds like little, but the eye notices.

Pulsedrop treats the beat as a clock. Once the spacing of the beats so far is known, the time of the next one is known too, and the picture is drawn for that time. The clock's speed and position are corrected a little with every new beat that is heard.

An illustration. White marks are the sound itself, gold is a picture that reacts after measuring, green one that knows the next beat and is drawn for it. Use the slider to make the analysis slower.

For the first few seconds, before the clock has settled on the song, the picture follows what is heard; then it moves over to the clock.

5. How many beats in a bar

Not every song counts in four. A waltz has three beats to the bar, and progressive rock uses meters such as 7/8. Pulsedrop does not assume a bar length; it finds it in the song.

The idea: music repeats a similar pattern in every bar. The first beat is strong, the next weaker, and so on. Cut the song into pieces of some length and lay the pieces over each other. If the strong hits pile up in the same places, that length is a bar. If the length is wrong, the pattern shifts from piece to piece and the pile shows nothing.

Cut a bar every how many steps?

At the right length the columns in 2 line up and the average in 3 shows clear highs and lows. Pick another length with the number buttons: the pattern slides sideways from row to row and the average goes flat.

The app scores every length from 3 to 14 steps this way. Besides how hard sounds start, the low drums, the high drums, the places where the chord changes and the model's own first-beat marks each have a vote. It is done for each section, so a change of meter in the middle of a song is followed.

The buttons above hold the analysis of Learning to Live by Dream Theater (1992), a song that changes meter often. A write-up of the song says the verses move between 7/4 and 6/4 and the bridge is in 4/4. Pulsedrop read 7/4 from 0:51, 6/4 for fifty seconds from 3:11, and 7/4 again from 4:01. The write-up gives no times, so the passages could not be matched one by one.

It also missed some. By the same write-up the intro is in 15/8, followed by bars of 14/8 and 13/8 in turn. Pulsedrop read that part as 4/4. As it stands, the method counts at most 14 steps to a bar and gives a section one meter, so a meter that changes every bar is not followed. On 120 songs with bars marked by people, the number of beats in a bar is right 90% of the time.

6. Finding the form of a song

When a verse gives way to the chorus, the picture should change too. For that the app has to know where the song divides and which parts come back.

It compares bars. For every bar it notes what the sound is like: how loud, how bright, how much bass, which chord. Then every bar is compared with every other bar, and the result is drawn as a table.

Both axes are time in the song. Each dot says how alike the bar at that time across is to the bar at that time down; brighter means more alike. A bright square along the diagonal is a stretch of similar bars: one section. The same square appearing away from the diagonal means that part returns elsewhere in the song. The coloured strip at the top is how Pulsedrop divided the song; the same letter is the same part.

Section boundaries come from two signals. One is a change of sound: if the few bars before a bar line differ from the few bars after it, that line is a candidate. Several bars are compared at once, so a single drum fill does not make a boundary.

The other is a change in what repeats. A verse and a chorus played by the same band at the same level can sound alike and differ only in their chords. For those, the app looks for the point where "which other bars of the song does this bar resemble" changes.

Once the boundaries are set, sections are compared and the same part gets the same letter. Loudness is left out of that comparison, so a last chorus played harder is still the chorus.

This part is not as good as a person yet. Scored on – live recordings whose form was marked by hand, boundaries within 3 s score –%. Two people marking the same song score –% against each other. Giving the same part the same letter scores –%, against –% between people.

7. A 22-minute song, whole

A song can change speed along the way. Pulsedrop measures the tempo every three seconds and joins the readings into a tempo map. So that one stray reading does not pull it away, a new tempo has to last over several readings before it counts as a change.

Illumination Theory, whole. Top: loudness. Middle: sections (height is intensity). Bottom: tempo. The song is known to end at 19:17, followed by about thirty seconds of silence and a hidden track. Pulsedrop read 19:15 to 19:47 as silence and puts no beats or bars there.

Mikael (Live), whole. One tempo from start to finish.

Silence is looked for on purpose. A program that counts beats keeps counting at the same spacing when the sound stops. Left alone, the picture would pulse through thirty seconds of nothing.

8. Mood is not volume

Pulsedrop picks presets that suit the music: calm pictures for calm songs, busy ones for intense songs. For that it has to know how intense the music is.

Loudness cannot be the measure. Recordings today are released at nearly the same level whatever the genre; a quiet ballad is as loud in the file as metal. So Pulsedrop looks at what the music is made of.

  • How hard and how often the drums hit, above all the high ones: snare and hi-hat.
  • Whether the sound is filled from low to high, or holds a few clear notes. Distorted guitars fill it; a solo piano does not.
  • How bright the sound is overall.

Averages over twelve songs per genre. The grey bars (loudness) hardly differ from jazz to disco. The green ones (intensity) separate the genres clearly. The reference values of the measure were set by looking at these same songs, so this figure cannot show how well it does on music it has not seen.

Loudness is still used inside a song, where it is useful: to tell the quiet passage of a song from its loud one.

9. It remembers songs it has heard

Live analysis is a guess made without knowing what comes next. Seeing the whole song first is far more accurate, and Pulsedrop arranges that wherever it can.

Playing a file

A file in the playlist is analysed whole in the background as soon as it starts. When that is done the picture follows the full analysis and not the live guess. The next file is analysed while the current one plays, so from the second song on, the first beat is already right.

Listening to Spotify or Apple Music

Here there is no file, only the sound coming out of the computer. Pulsedrop listens to it and does three things.

  • It checks what it has heard. About every 25 s, the last minute and a half is analysed again with the more accurate model. The live beat clock is compared with it: is it counting at double speed, has it taken the points between beats for beats, is the first beat of the bar right? What is wrong is corrected.
  • It remembers the song when it ends. The whole song is analysed once and kept under its title and artist. Only results are kept, such as beat times and sections, and no sound: a few dozen kilobytes per song.
  • It knows the song when it returns. When the same song plays again, the kept analysis is loaded. Where in the song we are is found by laying the rhythm of the last eight seconds over the rhythm that was kept. The position the player reports is only a rough starting point. Skip to the middle of the song and the place is found again within seconds.

A test: Mikael (Live) was played through once. Then it was played again from 0:37, quieter and with noise added, with the playback position reported half a second wrong. The place was found after – s. From then on the position error was mostly – ms and at worst – ms. This replayed the same recording; a version that sounds different, such as a remaster, may give other results.

10. Checking how right it is

Tune an analysis while looking at a few favourite songs and it will fit those songs. So it is scored on public data in which people marked the answers. The scoring code is in the repository.

WhatAnswers fromResult
Beats120 thirty-second songs in ten genres, beats tapped by people, not seen by the models in training (GTZAN)–% within 0.07 s
First beat of the barthe same 120–%
Speed of countingthe same 120same as people –%, double –%, half –%
Beats in a barthe same 120–%
Sections– live recordings with the form marked by hand (SALAMI)boundaries –%, letters –%. Between people: –% and –%
Time signaturetest songs made with a known answer: 3/4, 5/4, 7/4, 5/8, 7/8, 9/8, 12/8 and others, 13 in allall pass

You can run it yourself. node scripts/eval-fetch.mjs downloads the public recordings, then npx tsx scripts/eval-real.ts beats. Put form or mood in place of beats for the other scores.

What it does not do well yet

  • Section boundaries. Often a bar or two away from where people put them.
  • The first beat in jazz, classical and blues. It is often wrong in these genres.
  • Music without a beat. Music that flows without a steady beat is given a tempo anyway.
  • Sections of a song heard for the first time. Heard live, with nothing known of what follows, a song is cut into more sections than it has. A song heard to the end once uses the full analysis from then on.