简体   繁体   中英

Preview Score from MIDI file in python

I would like to be able to get png of a score from a MIDI file from within a python program.

Separately, I know MuseScore is able to open MIDI files and convert them into a score, so this should theoretically be possible.

My current solution is to just use the lilypond functions,midi2ly and.lilypond -fpng, but midi2ly struggles a bit with the midis I use due to the number of voices present.

!midi2ly "sample from g.midi"
!lilypond -fpng "sample from g-midi.ly"

Here is the ideal output (from MuseScore) and lilypond's attempt output https://imgur.com/a/9fqJLSA

Try music21!

import music21
parsed = music21.converter.parse('source.mid')
parsed.show('musicxml.png')

Use .write() rather than .show() if you don't want to launch a viewer.

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