Designs by Duhart All writing

·1 min read·machinelearning · musictech · featureengineering · audioprocessing · datascience

Can Math Tell a Catchy Melody From a Boring One? I Measured It

Melodic complexity, the entropy of a song's note-to-note intervals, measured by my music engine on 3,123 tracks. Frank Ocean outscores Für Elise, classical leads every genre, and none of it says what is catchy.

Cover slide: Can Math Tell a Catchy Melody From a Boring One? I Measured It. Bottom left, an "Interviewing at" badge with the logos of Spotify, Apple Music, YouTube Music, SoundCloud.

Melody without a transcription model

My engine has no music transcription model. It takes the pYIN pitch track from part 6 and segments it: a new note starts when the pitch moves more than half a semitone and stays there for 3 frames. From the notes come intervals, and from the intervals six numbers: complexity, notes per second, mean and spread of the interval size, range in semitones, direction changes per second, plus a 32-point contour of the excerpt.

Catchy vs complex in 40 seconds

Every number is from the stored records and the catalogue medians; sources at the end.
Opening frame of the video: Can Math Tell a Catchy Melody From a Boring One? I Measured It
Every number is from the stored records and the catalogue medians; sources at the end. Watch the video: https://designsbyduhart.org/blog/can-math-tell-a-catchy-melody-from-a-boring-one/

melody_analysis.py: complexity

python
bins = np.clip(np.round(intervals), -12, 12).astype(int) + 12
hist = np.bincount(bins, minlength=25).astype(float)
p = hist / hist.sum()
p = p[p > 0]
complexity = float(-(p * np.log2(p)).sum() / np.log2(25))

The verdict, by song

| song | complexity | |---|---| | White Ferrari | 0.894 | | Bach, cello prelude | 0.885 | | bad guy | 0.877 | | Für Elise | 0.856 | | Fat Lip | 0.791 | | Dracula | 0.770 |

Frank Ocean outscores Beethoven. That is not a ranking of taste: complexity is the variety of intervals in the line, and White Ferrari's vocal wanders more than Für Elise's famous figure.

The shape of a melody

Slide 3 of 8 of "Can Math Tell a Catchy Melody From a Boring One? I Measured It", near-black background, white Inter type with mono labels. The shape of a melody. A 32-point contour of each excerpt. Für Elise jumps; bad guy murmurs, then climbs. Chart or diagram from the video at its final state.
The 32-point contours of Für Elise and bad guy, normalised.

Melodic complexity by genre

Median complexity per catalogue genre. Hover for range and notes per second. Open full screen
Cover slide: Can Math Tell a Catchy Melody From a Boring One? I Measured It. Bottom left, an "Interviewing at" badge with the logos of Spotify, Apple Music, YouTube Music, SoundCloud.
Median complexity per catalogue genre. Hover for range and notes per second. Interactive version: https://designsbyduhart.org/blog/can-math-tell-a-catchy-melody-from-a-boring-one/

What audio can and cannot tell

Variety, range, speed and shape come straight from the audio. Catchiness does not: it shows up in what listeners do, replays, saves and skips, which is the feedback loop the recommender learns from later in Spotify Master. And without source separation the "melody" is whichever line dominates the mix: usually the lead vocal, sometimes a lead instrument.

Part 7 of 14, next: Finding the BPM of Any Song (and the Half-Time Trap Every Detector Falls Into).


Part 7 of 14, next: Finding the BPM of Any Song (and the Half-Time Trap Every Detector Falls Into).

More: LinkedIn · Instagram. Portfolio and case studies: designsbyduhart.org.

If any of this saved you an afternoon, Buy me a coffee.