Skip to content

Instantly share code, notes, and snippets.

@victormurcia
Created September 3, 2022 05:39
Show Gist options
  • Select an option

  • Save victormurcia/0d51982ea2a7f9c220cf9b3faac702d6 to your computer and use it in GitHub Desktop.

Select an option

Save victormurcia/0d51982ea2a7f9c220cf9b3faac702d6 to your computer and use it in GitHub Desktop.
make_midi
#Convert midi number column to a numpy array
midi_number = catterina_df['midi_number'].to_numpy()
degrees = list(midi_number) # MIDI note number
track = 0
channel = 0
time = 0 # In beats
duration = 1 # In beats
tempo = 240 # In BPM
volume = 100 # 0-127, as per the MIDI standard
MyMIDI = MIDIFile(1) # One track, defaults to format 1 (tempo track
# automatically created)
MyMIDI.addTempo(track,time, tempo)
for pitch in degrees:
MyMIDI.addNote(track, channel, pitch, time, duration, volume)
time = time + 1
with open("catterina.mid", "wb") as output_file:
MyMIDI.writeFile(output_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment