frescobaldi / python-ly

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

ly.musicxml cannot parse triplets made of chords #51

Open shimpe opened 8 years ago

shimpe commented 8 years ago

With current git version of python-ly

>>> import ly.musicxml
>>> e = ly.musicxml.writer()
>>> e.parse_text(" { \\tuplet 3/2 { <a c>8 <a e> <a c> } } ")

Traceback (most recent call last): File "", line 1, in File "python-ly/ly/musicxml/lymus2musxml.py", line 96, in parse_text self.parse_document(doc) File "python-ly/ly/musicxml/lymus2musxml.py", line 109, in parse_document self.parse_tree(mustree) File "python-ly/ly/musicxml/lymus2musxml.py", line 123, in parse_tree self.parse_nodes(mus_nodes) File "python-ly/ly/musicxml/lymus2musxml.py", line 135, in parse_nodes func_call(m) File "python-ly/ly/musicxml/lymus2musxml.py", line 566, in End self.mediator.change_tuplet_type(len(self.tuplet) - 1, "stop") File "python-ly/ly/musicxml/ly2xml_mediator.py", line 588, in change_tuplet_type self.current_note.tuplet[index].ttype = newtype IndexError: list index out of range

PeterBjuhr commented 8 years ago

Thanks for reporting!

shimpe commented 8 years ago

Thanks for fixing! It works now :)

wbsoft commented 8 years ago

The same error pops up with this (Mutopa) file (reporter by a user), when exporting to MusicXML. http://www.mutopiaproject.org/ftp/SchubertF/D493/SchubertF-D493_DerWanderer/SchubertF-D493_DerWanderer.ly (with 0.9.4 and current git)

PeterBjuhr commented 8 years ago

I guess that means we'll have to reopen the issue!

cguckes commented 7 years ago

Got the same issue:

Traceback (most recent call last):
  File "/usr/share/frescobaldi/frescobaldi_app/file_export/__init__.py", line 65, in exportMusicXML
    writer.parse_text(doc.toPlainText(), orgname)
  File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 102, in parse_text
    self.parse_document(doc)
  File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 119, in parse_document
    self.parse_tree(mustree)
  File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 133, in parse_tree
    self.parse_nodes(mus_nodes)
  File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 145, in parse_nodes
    func_call(m)
  File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 587, in End
    self.mediator.change_tuplet_type(len(self.tuplet) - 1, "stop")
  File "/usr/lib/python3/dist-packages/ly/musicxml/ly2xml_mediator.py", line 596, in change_tuplet_type
    self.current_note.tuplet[index].ttype = newtype
IndexError: list index out of range

I attached the files producing the error. I don't know what the exact problem is, so I can't give you a smaller example. failing-tuplets.zip