2

我正在尝试将 MuseScore 3 用作小型音乐片段的某种编辑器,例如从 MusicXML 文件打开的童谣。

然而,我尝试使用 Frescobaldi Python 库python-ly似乎会导致使用该库生成的 MusicXML 文件出现一些非常奇怪的导入错误。

我该怎么做呢?有可能吗?

我写了一些 LilyPond 文件,例如“Old MacDonald has a farm”,包括主旋律(音符)、歌词、四弦琴标签和和弦:

% 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 }
>> }

它通过 LaTeX 呈现lyluatex为 PDF 片段,如下所示:

在此处输入图像描述

然后在 Python 方面,我将此old-macdonald-had-a-farm.ly文件导出到 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')

最后我打开 MuseScore 3 的 GUI,点击 File > Open,然后打开old-macdonald-had-a-farm.xml,然后我发现弹出窗口中有很多非常严重但奇怪的错误:

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

乐谱对我来说似乎很好(见上面的截图)。

然后在 MuseScore 3 上看起来像:

在此处输入图像描述

我很难看出上述过程有什么问题。

是因为 LilyPond 文件必须以非常简单的方式编写,例如只有旋律音符,还是我正在做的事情有什么问题?

4

0 回答 0