Skip to content

Commit 1da695d

Browse files
committed
CreateMusicXML: add method add_ending() and hook it up.
1 parent dbb117f commit 1da695d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ly/musicxml/create_musicxml.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,20 @@ def add_barline(self, bl_type, repeat=None, repeat_times=None):
540540
if repeat_times and repeat_times > 2:
541541
repeatnode.attrib['times'] = str(repeat_times)
542542

543+
def add_ending(self, ending, number):
544+
barnode = etree.SubElement(self.current_bar, "barline", location="right")
545+
546+
if not(isinstance(number,list)):
547+
number = [number]
548+
549+
number_attr = ','.join(str(n) for n in number)
550+
551+
endingnode = etree.SubElement(barnode, "ending", type=ending, number=number_attr)
552+
553+
if ending == 'start':
554+
barnode.attrib['location'] = 'left'
555+
endingnode.text = ', '.join('{}.'.format(n) for n in number)
556+
543557
def add_backup(self, duration):
544558
if duration <= 0:
545559
return

ly/musicxml/xml_objs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def new_xml_bar_attr(self, obj):
126126
self.musxml.add_barline(obj.barline, obj.repeat, obj.repeat_times)
127127
elif obj.barline:
128128
self.musxml.add_barline(obj.barline)
129+
elif obj.ending:
130+
self.musxml.add_ending(obj.ending, obj.ending_number)
129131
if obj.staves:
130132
self.musxml.add_staves(obj.staves)
131133
if obj.multiclef:

0 commit comments

Comments
 (0)