lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: musicXML: 2 staves, piano


From: Jacques Menu
Subject: Re: musicXML: 2 staves, piano
Date: Sat, 25 Sep 2021 00:09:44 +0200

Hello folks,

Sorry for this rather long answer.

The problem with hello1.xml is that the <staff /> elements are misplaced.
Fixing that as shown at the bottom of this message solves the issue.

MuseScore does a good job at checking that MusicXML data complies to the DTD, that has the following specification for the note element:

<!ELEMENT note
(((grace, ((%full-note;, (tie, tie?)?) | (cue, %full-note;))) |
 (cue, %full-note;, duration) |
 (%full-note;, duration, (tie, tie?)?)),
instrument?, %editorial-voice;, type?, dot*,
accidental?, time-modification?, stem?, notehead?,
notehead-text?, staff?, beam*, notations*, lyric*, play?)>

MuseScore's message it issues is not perfect though:

Opening the file anyway by choosing ‘Yes’ leads to the expected score:


A systematical, thorough check of MusicXML files can be done at https://validator.w3.org .

xml2ly does not check full DTD compliance, it does so only for its own safety, i.e. to avoid crashes. It succeeds with the orignal hello1.xml without any error message:

jacquesmenu@macmini: ~/Desktop > xml2ly hello1.xml -auto-output-file-name
jacquesmenu@macmini: ~/Desktop > cat hello1.ly 
\version "2.22.0"

% Pick your choice from the next two lines as needed
%myBreak = { \break }
myBreak = {}

% Pick your choice from the next two lines as needed
%myPageBreak = { \break }
myPageBreak = {}

\header {
  title                = ""
}

\paper {
}

\layout {
  \context {
    \Score
    autoBeaming = ##f % to display tuplets brackets
  }
  \context {
    \Voice
  }
}

Part_POne_Staff_One_Voice_One = \absolute {
  \language "nederlands"
  \key g \major
  \numericTimeSignature \time 2/4
  
  \clef "treble"
  c'2 | % 1
  \barNumberCheck #2
  | % 1
  \barNumberCheck #2
}

Part_POne_Staff_Two_Voice_One = \absolute {
  \language "nederlands"
  \key g \major
  \numericTimeSignature \time 2/4
  
  \clef "bass"
  d2 | % 2
  \barNumberCheck #2
  | % 2
  \barNumberCheck #2
}

\book {
  \score {
    <<
      
      \new PianoStaff
      \with {
        instrumentName = "Music"
      }
       <<
      \new Staff = "Part_POne_Staff_One"
      \with {
      }
      <<
        \context Voice = "Part_POne_Staff_One_Voice_One" <<
          \Part_POne_Staff_One_Voice_One
        >>
      >>
      
      \new Staff = "Part_POne_Staff_Two"
      \with {
      }
      <<
        \context Voice = "Part_POne_Staff_Two_Voice_One" <<
          \Part_POne_Staff_Two_Voice_One
        >>
      >>
      >>
      
    >>
    
    \layout {
      \context {
        \Score
        autoBeaming = ##f % to display tuplets brackets
      }
      \context {
        \Voice
      }
    }
    
    \midi {
      \tempo 16 = 360
    }
  }
  
}

Dmitry, how do you generate MusicXML data?

JM


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC
    "-//Recordare//DTD MusicXML 4.0 Partwise//EN"
<score-partwise version="4.0">
  <part-list>
    <score-part id="P1">
      <part-name>Music</part-name>
      <score-instrument id="Piano">
        <instrument-name>Piano</instrument-name>
      </score-instrument>
    </score-part>
  </part-list>
  <part id="P1">
    <measure number="1">
      <attributes>
        <divisions>1</divisions>
        <key>
          <fifths>1</fifths>
        </key>
        <time>
          <beats>2</beats>
          <beat-type>4</beat-type>
        </time>
        <staves>2</staves>
        <clef number="1">
          <sign>G</sign>
          <line>2</line>
        </clef>
        <clef number="2">
          <sign>F</sign>
          <line>4</line>
        </clef>
      </attributes>
      <note>
        <pitch>
          <step>C</step>
          <alter>0</alter>
          <octave>4</octave>
        </pitch>
        <duration>2</duration>
        <type>half</type>
        <staff>1</staff>
      </note>
      <backup>
        <duration>2</duration>
      </backup>
      <note>
        <pitch>
          <step>D</step>
          <alter>0</alter>
          <octave>3</octave>
        </pitch>
        <duration>2</duration>
        <type>half</type>
        <staff>2</staff>
      </note>
    </measure>
  </part>
</score-partwise>

Le 24 sept. 2021 à 23:10, Carl Sorensen <c_sorensen@byu.edu> a écrit :



On 9/24/21, 2:52 PM, "Thomas Morley" <thomasmorley65@gmail.com> wrote:

   Am Fr., 24. Sept. 2021 um 22:33 Uhr schrieb Carl Sorensen <c_sorensen@byu.edu>:

We have automatic tests for xml2ly that check compliance with the musicXML standard.

I'm fairly certain it's a problem with your musicXML, rather than xml2ly.

Unfortunately, I'm not expert enough on musicXML to find the mistakes.

Why are your writing your own musicXML and then using xml2ly, instead of just writing in lilypond?

Carl




   Hi Carl,

   iiuc, xml2ly converts an .xml-file to a .ly-file, not the other way round.

Yes, I know this.  As far as I can see, Dmitry is writing musicXML files by hand (which I cannot imagine doing) and then importing them to lilypond using xml2ly.



   Speaking of it, I recently tested several methods to convert ly to xml:
   (1) openlilylib (with lilypond-export, Jan-Peter)
   (2) python-ly
   (3) Frescobaldi
   (4) de Wolff (https://github.com/de-wolff/lilypond.git)

   and converted the resulting files back to ly with musicxml2ly
   (builtin) and xml2ly (https://github.com/grame-cncm/libmusicxml.git,
   xml2ly by Jacques)

   The results were terrible :((

I totally agree that the musicXML export tools are really not good at all.

   I was tempted to offer a very high bounty to get a working xml-export.
   Alas, we already have
   https://gitlab.com/lilypond/lilypond/-/issues/665 and the there
   offered bounties are not that low ...

I think that a good musicXML export project is likely a 6-month, full-time project for an expert in lilypond.  For that kind of effort, a 1,000 euro bounty is not big.

Thanks,

Carl


reply via email to

[Prev in Thread] Current Thread [Next in Thread]