Skip to content

Commit 8f233fb

Browse files
committed
added partial-pickup feature
1 parent f96544e commit 8f233fb

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

ly/musicxml/create_musicxml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ def create_part(self, name="unnamed", abbr=False, midi=False):
112112
self.part_count += 1
113113
self.bar_nr = 1
114114

115-
def create_measure(self, **bar_attrs):
115+
def create_measure(self, pickup = False, **bar_attrs):
116116
"""Create new measure """
117+
if pickup and self.bar_nr == 1:
118+
self.bar_nr = 0
117119
self.current_bar = etree.SubElement(self.current_part, "measure", number=str(self.bar_nr))
118120
self.bar_nr +=1
119121
if bar_attrs:

ly/musicxml/ly2xml_mediator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(self):
7676
self.prev_tremolo = 8
7777
self.tupl_dur = 0
7878
self.tupl_sum = 0
79+
self.bar_is_pickup = False
7980

8081
def new_header_assignment(self, name, value):
8182
"""Distributing header information."""
@@ -309,11 +310,17 @@ def get_first_var(self):
309310
if self.sections:
310311
return self.sections[0].barlist
311312

313+
def set_pickup(self):
314+
self.bar_is_pickup = True
315+
312316
def new_bar(self, fill_prev=True):
313317
if self.bar and fill_prev:
314318
self.bar.list_full = True
315319
self.current_attr = xml_objs.BarAttr()
316320
self.bar = xml_objs.Bar()
321+
if self.bar_is_pickup:
322+
self.bar.pickup = True
323+
self.bar_is_pickup = False
317324
self.bar.obj_list = [self.current_attr]
318325
self.insert_into.barlist.append(self.bar)
319326

ly/musicxml/lymus2musxml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def Duration(self, duration):
345345
self.mediator.set_tuplspan_dur(duration.token, duration.tokens)
346346
self.tupl_span = False
347347
elif self.pickup:
348-
#TO DO
348+
self.mediator.set_pickup()
349349
self.pickup = False
350350
else:
351351
self.mediator.new_duration_token(duration.token, duration.tokens)

ly/musicxml/xml_objs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def iterate_part(self, part):
102102

103103
def iterate_bar(self, bar):
104104
"""The objects in the bar are output to the xml-file."""
105-
self.musxml.create_measure()
105+
self.musxml.create_measure(pickup = bar.pickup)
106106
for obj in bar.obj_list:
107107
if isinstance(obj, BarAttr):
108108
self.new_xml_bar_attr(obj)
@@ -432,6 +432,7 @@ class Bar():
432432
Contains also information about how complete it is."""
433433
def __init__(self):
434434
self.obj_list = []
435+
self.pickup = False
435436
self.list_full = False
436437

437438
def __repr__(self):

tests/test_xml_files/pickup.ly

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)