diff --git a/ly/musicxml/create_musicxml.py b/ly/musicxml/create_musicxml.py index 8fb82b7b..1972ab42 100644 --- a/ly/musicxml/create_musicxml.py +++ b/ly/musicxml/create_musicxml.py @@ -528,6 +528,9 @@ def add_clef(self, sign, line, nr=0, oct_ch=0): octchnode = etree.SubElement(clefnode, "clef-octave-change") octchnode.text = str(oct_ch) + def new_system(self, force_break): + etree.SubElement(self.current_bar, "print", {'new-system':force_break}) + def add_barline(self, bl_type, repeat=None): barnode = etree.SubElement(self.current_bar, "barline", location="right") barstyle = etree.SubElement(barnode, "bar-style") diff --git a/ly/musicxml/ly2xml_mediator.py b/ly/musicxml/ly2xml_mediator.py index a9ec6951..47a1712e 100644 --- a/ly/musicxml/ly2xml_mediator.py +++ b/ly/musicxml/ly2xml_mediator.py @@ -867,6 +867,10 @@ def check_divs(self): mult = get_mult(a, b) self.divisions = divs*mult + def add_break(self): + if self.bar is None: + self.new_bar() + self.current_attr.add_break('yes') ## diff --git a/ly/musicxml/lymus2musxml.py b/ly/musicxml/lymus2musxml.py index 13dfb733..2e654622 100644 --- a/ly/musicxml/lymus2musxml.py +++ b/ly/musicxml/lymus2musxml.py @@ -497,6 +497,8 @@ def Command(self, command): if self.tupl_span: self.mediator.unset_tuplspan_dur() self.tupl_span = False + elif command.token == '\\break': + self.mediator.add_break() else: if command.token not in excls: print("Unknown command:", command.token) diff --git a/ly/musicxml/xml_objs.py b/ly/musicxml/xml_objs.py index bad1e057..fbb8bb04 100644 --- a/ly/musicxml/xml_objs.py +++ b/ly/musicxml/xml_objs.py @@ -122,6 +122,8 @@ def new_xml_bar_attr(self, obj): """Create bar attribute xml-nodes.""" if obj.has_attr(): self.musxml.new_bar_attr(obj.clef, obj.time, obj.key, obj.mode, obj.divs) + if obj.new_system: + self.musxml.new_system(obj.new_system) if obj.repeat: self.musxml.add_barline(obj.barline, obj.repeat) elif obj.barline: @@ -726,10 +728,14 @@ def __init__(self): self.staves = 0 self.multiclef = [] self.tempo = None + self.new_system = None def __repr__(self): return '<{0} {1}>'.format(self.__class__.__name__, self.time) + def add_break(self, force_break): + self.new_system = force_break + def set_key(self, muskey, mode): self.key = muskey self.mode = mode diff --git a/tests/test_xml.py b/tests/test_xml.py index e25f6ae5..679cb5bd 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -30,6 +30,8 @@ def test_dynamics(): def test_tuplet(): compare_output('tuplet') +def test_break(): + compare_output('break') def ly_to_xml(filename): """Read Lilypond file and return XML string.""" diff --git a/tests/test_xml_files/break.ly b/tests/test_xml_files/break.ly new file mode 100644 index 00000000..565db371 --- /dev/null +++ b/tests/test_xml_files/break.ly @@ -0,0 +1,4 @@ +\relative c'' { + c4 c c c | \break + c4 c c c | +} \ No newline at end of file diff --git a/tests/test_xml_files/break.xml b/tests/test_xml_files/break.xml new file mode 100644 index 00000000..4cca3162 --- /dev/null +++ b/tests/test_xml_files/break.xml @@ -0,0 +1,106 @@ + + + + + + python-ly 0.9.5 + 2017-05-14 + + + + + + + + + + + 1 + + + G + 2 + + + + + C + 5 + + 1 + 1 + quarter + + + + C + 5 + + 1 + 1 + quarter + + + + C + 5 + + 1 + 1 + quarter + + + + C + 5 + + 1 + 1 + quarter + + + + + + C + 5 + + 1 + 1 + quarter + + + + C + 5 + + 1 + 1 + quarter + + + + C + 5 + + 1 + 1 + quarter + + + + C + 5 + + 1 + 1 + quarter + + + + +