I am trying to use MuseScore 3 as some sort of editor for small music snippets e.g. nursery rhymes opened from MusicXML files.
However my attempts to use the Frescobaldi Python library python-ly
seem to lead to some very weird import errors on the MusicXML file generated with this library.
How do I do this? Is it possible at all?
I've written some LilyPond files for e.g. "Old MacDonald has a farm" to include the main melody (notes), lyrics, Ukulele tab and chords:
% command `lilypond --version`
\version "2.20.0"
mymelody = {
\time 4/4
\tempo 4 = 70
\key g \major
g'4 g'4 g'4 d'4 \bar "|" e'4 e'4 d'2 \bar "|" b'4 b'4 a'4 a'4 \bar "|" g'1
}
mychords = \chordmode {
g'1 \bar "|" c'2 d'2 \bar "|" g'2 d'2 \bar "|" g'1
}
mylyrics = \lyricmode {
old Mac -- Do -- nald had a farm, E -- I E -- I Oh
}
% https://lilypondcookbook.com/post/83531286313/fretted-strings-3-string-specific-notation
\score { \new StaffGroup <<
\new ChordNames { << \mychords >> }
\new Voice = "mywords" { << \mymelody >> }
\new Lyrics = "mywords"
\context Lyrics = "mywords" {
\lyricsto "mywords" {
\mylyrics
}
}
\new TabStaff \with { stringTunings = #ukulele-tuning } { \mymelody }
>> }
which rendered via LaTeX with lyluatex
as a PDF snippet looks like:
Then on the Python side of things I've exported this old-macdonald-had-a-farm.ly
file to MusicXML:
# pip install python-ly
# https://python-ly.readthedocs.io/en/latest/ly.musicxml.html
import ly.musicxml
import ly.document
e = ly.musicxml.writer()
# https://python-ly.readthedocs.io/en/latest/_modules/ly/document.html#Document.load
ly_doc = ly.document.Document.load('songs/ly/old-macdonald-had-a-farm.ly')
e.parse_text(ly_doc.plaintext())
ly_doc_xml = e.musicxml()
ly_doc_xml.write('songs/ly/old-macdonald-had-a-farm.xml')
Finally I opened the GUI for MuseScore 3, clicked on File > Open, then opened old-macdonald-had-a-farm.xml
, then I found out there are lots of very serious, but weird, errors in the pop-up window:
Bar 9, stave 1 incomplete. Expected: 4/4; Found: 7/4
Bar 9, stave 2 incomplete. Expected: 4/4; Found: 7/4
Bar 9, stave 3 incomplete. Expected: 4/4; Found: 7/4
Bar 11, stave 1 incomplete. Expected: 4/4; Found: 5/4
Bar 11, stave 2 incomplete. Expected: 4/4; Found: 5/4
Bar 11, stave 3 incomplete. Expected: 4/4; Found: 5/4
Bar 13, stave 1 incomplete. Expected: 4/4; Found: 6/4
Bar 13, stave 2 incomplete. Expected: 4/4; Found: 6/4
Bar 13, stave 3 incomplete. Expected: 4/4; Found: 6/4
The music score seems fine to me (see the screenshot above).
Then on MuseScore 3 looks like:
I struggle to see what is wrong with the process described above.
Is it because LilyPond files must be written in very simple ways e.g. only the melody notes, or what is wrong with what I am doing?
\midi{}
in the\score
block, generates a MIDI file, and MuseScore can open MIDI files. – Commend