Recently i started to try and learn more songs on guitar by ear. An important part of doing that is learning which key is the song in. So I thought it would be useful to see the distribution of the notes in the song to figure that out.
I started looking up how could I get the note data. After looking at a bunch of different formats for storing music data I decided to first test with MIDI, as it is a pretty common format and had a well documented library.
After some reading and exploring in a Jupyter Notebook i wrote a couple functions to extract the note data and count it. Then i plotted the result with Matplotlib.
The MIDI files that I had for my first tests were exported from a Guitar Pro file. So I decided to add the posibility to get data from Guitar Pro Files directly and skip having to export each song manually. For this i used the PyGuitarPro Library.
Some extra examples
Cementary Gates - Pantera
Dystopia - Megadeth
Inmortal Melancholy - Epica
Bohemian Rhapsody - Queen
All the code for the visualizations is available in the “Source code” button at the top of the page.