Skip to content

Instantly share code, notes, and snippets.

@calippo
Last active November 7, 2017 22:04
Show Gist options
  • Save calippo/41cd90e83c055d5c30de3ba7650d2f5c to your computer and use it in GitHub Desktop.
Save calippo/41cd90e83c055d5c30de3ba7650d2f5c to your computer and use it in GitHub Desktop.
python-midi example
import midi #pip install python-midi (https://github.com/vishnubob/python-midi)
pattern = midi.Pattern()
track = midi.Track()
pattern.append(track)
on = midi.NoteOnEvent(tick=0, velocity=100, pitch=60)
track.append(on)
off = midi.NoteOffEvent(tick=100, pitch=60)
track.append(off)
eot = midi.EndOfTrackEvent(tick=1)
track.append(eot)
midi.write_midifile("outfile.mid", pattern)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment