Export LilyPond file to MusicXML then importing that into MuseScore
Asked Answered
S

0

7

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:

enter image description here

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:

enter image description here

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?

Stichometry answered 27/1, 2022 at 20:18 Comment(3)
I don't understand why you are using: Frescobaldi, Python, LaTeX, or MusicXML. Compiling a LilyPond file which includes the command \midi{} in the \score block, generates a MIDI file, and MuseScore can open MIDI files.Commend
@ElementsinSpace, most notation aimed musicians prefer MusicXML over MIDI because MIDI doesn't care about articulations, enharmonics, and other notation-only issues. It can only tell how long and what pitch a note is (and some other audio-related parameters), which in a lot of situations is not very useful for notation. For "Old MacDonald has a farm" isn't a real issue, it's actually faster to rewrite it in MuseScore, but for more complex scores, MusicXML saves a lot of editing time.Clink
I'm curious to know whether the OP ever found a solution for this.Epirogeny

© 2022 - 2024 — McMap. All rights reserved.