From 869c0125f85bf4b1699e76588d0abb32ccc59ccc Mon Sep 17 00:00:00 2001 From: Endre Oma Date: Fri, 7 Apr 2017 17:56:03 +0200 Subject: [PATCH 1/2] MusicXML: recognize \partial --- ly/musicxml/lymus2musxml.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ly/musicxml/lymus2musxml.py b/ly/musicxml/lymus2musxml.py index 13dfb733..b14427af 100644 --- a/ly/musicxml/lymus2musxml.py +++ b/ly/musicxml/lymus2musxml.py @@ -331,6 +331,12 @@ def check_tuplet(self): def Duration(self, duration): """A written duration""" + + if isinstance(duration.parent(), ly.music.items.Partial): + # No need to handle the duration element for a \partial element + # unless barcheck should be implemented + return + if self.tempo: self.mediator.new_tempo(duration.token, duration.tokens, *self.tempo) self.tempo = () @@ -550,6 +556,10 @@ def LyricMode(self, lyricmode): r"""A \lyricmode, \lyrics or \addlyrics expression.""" self.alt_mode = 'lyric' + def Partial(self, partial): + r"""A \partial node""" + pass + def Override(self, override): r"""An \override command.""" self.override_key = '' From 0ce48f7ab940c143c436e263c2cb08519a09c436 Mon Sep 17 00:00:00 2001 From: Endre Oma Date: Fri, 7 Apr 2017 17:57:30 +0200 Subject: [PATCH 2/2] Add test for \partial --- tests/test_xml.py | 4 +++ tests/test_xml_files/partial.ly | 6 ++++ tests/test_xml_files/partial.xml | 61 ++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 tests/test_xml_files/partial.ly create mode 100644 tests/test_xml_files/partial.xml diff --git a/tests/test_xml.py b/tests/test_xml.py index e25f6ae5..e447ffe1 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -31,6 +31,10 @@ def test_tuplet(): compare_output('tuplet') +def test_partial(): + compare_output('partial') + + def ly_to_xml(filename): """Read Lilypond file and return XML string.""" writer = ly.musicxml.writer() diff --git a/tests/test_xml_files/partial.ly b/tests/test_xml_files/partial.ly new file mode 100644 index 00000000..057cbf22 --- /dev/null +++ b/tests/test_xml_files/partial.ly @@ -0,0 +1,6 @@ +\score { + \relative c' { + \partial 4 c8 c | d1 | + } + \layout{} +} diff --git a/tests/test_xml_files/partial.xml b/tests/test_xml_files/partial.xml new file mode 100644 index 00000000..646877da --- /dev/null +++ b/tests/test_xml_files/partial.xml @@ -0,0 +1,61 @@ + + + + + + python-ly 0.9.5 + 2017-04-07 + + + + + + + + + + + 2 + + + G + 2 + + + + + C + 4 + + 1 + 1 + eighth + + + + C + 4 + + 1 + 1 + eighth + + + + + + D + 4 + + 8 + 1 + whole + + + + +