Phil Brockman
Phil Brockman

Reputation: 350

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://i.sstatic.net/LZ0zL.jpg

Upvotes: 2

Views: 1587

Answers (1)

Jacob Walls
Jacob Walls

Reputation: 861

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.

Upvotes: 1

Related Questions