frescobaldi / python-ly

A Python package and commandline tool to manipulate LilyPond files
https://pypi.org/project/python-ly
136 stars 35 forks source link

Chord names not working in MusicXML conversion #141

Open kwertyops opened 4 years ago

kwertyops commented 4 years ago

Here is a Lilypond file that produces a staff with a melody and annotated chord names above the staff:

\version "2.13.2"

\score
{
<<

    \new ChordNames { \chords {
      | bes1:6 
      | bes2:6 g2:7 | c2:min7 f2:7 | bes2 g2:min7 | c2:min7 f2:7 | f2:min7 bes2:7 | es2:7 aes2:7 | d2:min7 g2:7 | c2:min7 f2:7 |
      }
      }

    \new Staff
    <<
    {

      | f'4 es'8. bes16 des'4 es'4 
      \bar "||" \mark \default bes4 bes4. r8 r4 
      | r1 
      | r2 d4 a8 c'8~ 
      | c'16 bes8 g16~ g8 bes8 des'4 c'8 bes8 
      | c'4. bes8 aes8 c'8 b8 a8 
      | bes8 fis8~ \tuplet 3/2 {fis8 g8 bes8} des'8. aes16 cis'8 d'8 
      | bes8 c'8 g8 bes4 bes8 r4 
      | r1 |
    }
    >>
>>    
}

Rendered normally with Lilypond, the result is this:

Screen Shot 2020-05-30 at 11 49 06 AM

When converted to MusicXML using python-ly, the resulting MusicXML looks like this (rendered using MuseScore):

Screen Shot 2020-05-30 at 11 46 26 AM

I can confirm that this visualization matches the underlying XML, I'm including the image only because it's easier to see the discrepancy. So, it appears that when converted to MusicXML, this piece produces the correct melody, but with two major problems (ignoring the double-bar line becoming a measure, which seems like a separate problem):

  1. It contains none of the accompanying chord symbols.
  2. There are additional measures beyond what is written that contain additional whole and half notes at the end of the piece (this is confirmed by looking at the raw XML). These notes seem to correspond to the roots of the chords that were specified in the chord block.

During conversion from ly to xml, the following repeated errors are reported (this is just a snippet, they appear repeatedly, presumably once for each chord symbol in the original):

...
Warning: ChordSpecifier not implemented!
'ParseSource' object has no attribute 'ChordSpecifier'
Warning: ChordItem not implemented!
'ParseSource' object has no attribute 'ChordItem'
Warning: ChordItem not implemented!
'ParseSource' object has no attribute 'ChordItem'
Warning: ChordSpecifier not implemented!
'ParseSource' object has no attribute 'ChordSpecifier'
Warning: ChordItem not implemented!
'ParseSource' object has no attribute 'ChordItem'
Warning: ChordItem not implemented!
'ParseSource' object has no attribute 'ChordItem'
Warning: ChordSpecifier not implemented!
...
leonard-l-thompson commented 3 years ago

I appreciate this, as I'm interested in Chordnames export functionality as well. I would add also that attempts to render notated polyphony (as opposed to chord sysmbols) via \chordmode input produces the same sort of undesired xml output as above. So, in lilypond, \new Staff \new Voice \chordmode { g:7 } will produce four pitches ( g, b, d, f) on the staff without a problem, but xml export is not yet capable of interpreting the same expression, it seems.