简体   繁体   中英

Generating a sequence of MIDI numbers from an arbitrary MIDI file in python

I'm in the process of creating an app that reads a sheet and then generates a sequence of piano keys to be pressed in order for the sheet to be "played". I managed to get the MusicXML or MIDI file for my sheets. MIDI format is exactly what I need since there's a one to one correspondence between a MIDI number and a key on the piano (according to http://newt.phys.unsw.edu.au/jw/notes.html ) and it simpler than mapping each note of in the MusicXML file to a key. However I cannot access MIDI numbers themselves and MIDI editors (like MuseScore) only show the notation not the actual numbers. Is there a way to generate the sequence of MIDI numbers for a MIDI file in python?

you can use the python-midi library ( https://github.com/vishnubob/python-midi ) to parse a midi file and access the midi-data

have a look at the midi-dump script (in the script folder)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM