A few weeks ago, Lottie glanced at the piano and wondered if I could do a visualization relating to music.

I found a dataset containing hundreds of pieces of classical music in MIDI format, from the MAESTRO Dataset. (It also has audio files, but I didn’t need to use them for this.)

I extracted all of the musical notes from the files, broken down by composer, and produced bar charts in the style of a piano keyboard for each of them.

Each key is enlarged (or shrunk) in proportion to how often that note appears in all the composer’s pieces in this dataset.

This is what Bach’s chart looks like, based on 83 of his pieces:

Bach notes

You can compare different composers by trying out the interactive version here.

Some composers have more pieces than others in the MAESTRO Dataset, so their charts are likely to be more representative of their typical musical style as a whole. (The number of pieces is in brackets by each composer’s name.) I tried to remove duplicate pieces by a composer to avoid double counting, but this is an inexact process (by fuzzy matching on name) so some duplicates no doubt remain.

The full list of composers and pieces can be found in this file (CSV).

(Note that since the white keys on a piano keyboard are bigger than the black keys, the total area of the keyboard is not strictly preserved by these distortions. For example, if a composer favours white keys on average, then their keyboard will be bigger in area than the normal keyboard. I’m not sure that this matters too much for the purposes of this visualization. Update: following a suggestion from my friend Adrian Cook, I’ve created a version where all keys are the same height. This helps in comparing major and minor keys.)

Visualization type: animated bar charts

Data source: The MAESTRO Dataset, V2.0.0, MIDI, 85 MB

Technical notes: generated using d3; code