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.

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

melody_analysis.py: complexity
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

Melodic complexity by genre

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.