https://bgoonz-blog.netlify.app/docs/audio/

  1. About This Site (ipynb) Start here!
  2. About the CCRMA Workshop on Music Information Retrieval (ipynb)
  3. What is MIR? (ipynb)
  4. SoX and ffmpeg (ipynb)
  5. Alphabetical Index of Terms (ipynb)
  6. Short-time Fourier Transform and Spectrogram (ipynb)
  7. Video: Chroma Features (ipynb)
  8. Onset-based Segmentation with Backtracking (ipynb)

Determining the key of BWV1001 - 1st Movement, Adagio

Let's get weird with Bach: find the key of BWV10001 just by loading and parsing the MIDI file.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b5f34163-aa04-4c9a-af5c-ebd68fd25d91/1650fd57388f8c60c592727a076ad22bffc6e534cb3ff2e3c3387da7f2e902560a81750c910d57b76d3328ce1a1158a8b3ddff303558bac8555b09983dd3b992

I’m loading these MIDI files, from a separate server because the Internet Archive doesn't do CORS requests.

We’re looking at BWV1001 - 1st Movement, Adagio, by Johann Sebastian Bach.

Load a MIDI file and convert it using MIDIConvert to get a nice JSON representation. MIDI is both a real-time protocol, a physical connector, and a file format: this is the file format, a format that contains musical information.

Unlike MP3 and its descendents, MIDI stores individual notes and instruments that your computer recreates when it plays the file - it does not store the sound waves. Which is bad for the texture of the music - MIDI files have a characteristic cheesiness - but great for doing quick music analysis.

Chart all the notes. I’ll use vega-lite for this. MIDI has a 'note' representation that’s just a number, because computers store everything as numbers, at the lowest level.

First, combine all notes from all instruments. We don’t particularly care which instrument makes which tone in this case.

Now I want to get a feeling for the key: the notes in this piece, by number of appearances, irregardless of octave, translated from their MIDI numbers into note names.