Upload MIDI file:

See this as an example of how to use this script. Replace the contents of the "bulkdata" folder with the output from this script to swap out the song.

Output format is a list of binary-packed time "blocks" so that notes in the song can be indexed in O(1) time.

Each block can be split into a sequence of 8-bit integers. Starting with the least-significant bits, these 8-bit numbers represent as follows:

  1. Bits 0-7: Starting time of the 1st note within the block. 1 represents the start of the block; 255 represents the end of the block. 0 is a sentinel value meaning "no note."
  2. Bits 8-15: Frequency of the 1st note in semitones, where 60 is middle C.
  3. Bits 16-23: Starting time of the 2nd note in the same format as Bits 0-7.
  4. Bits 24-31: Frequency of the 2nd note in semitones in the same format as Bits 8-15.
  5. Bits 32-39: Time for the 3rd note.
  6. Bits 40-47: Freq for the 3rd note.