Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ly/musicxml/create_musicxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions ly/musicxml/ly2xml_mediator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')


##
Expand Down
2 changes: 2 additions & 0 deletions ly/musicxml/lymus2musxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions ly/musicxml/xml_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_xml_files/break.ly
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\relative c'' {
c4 c c c | \break
c4 c c c |
}
106 changes: 106 additions & 0 deletions tests/test_xml_files/break.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN"
"http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.0">
<identification>
<encoding>
<software>python-ly 0.9.5</software>
<encoding-date>2017-05-14</encoding-date>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name />
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
<time symbol="common">
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
</measure>
<measure number="2">
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
</measure>
<measure number="3" />
</part>
</score-partwise>