@@ -85,7 +85,7 @@ def write_harmony(parent, value: dict, divisions: int) -> None:
|
||||
item = element(node, 'root')
|
||||
element(item, 'root-step', root['letter'].upper())
|
||||
element(item, 'root-alter', decimal(root['alter']))
|
||||
element(node, 'kind', value['kind'], text=value.get('kind_text'))
|
||||
element(node, 'kind', value['kind'], text=harmony.symbol(value) if value.get('parenthesized') else None)
|
||||
if 'inversion' in value:
|
||||
element(node, 'inversion', value['inversion'])
|
||||
if 'bass' in value:
|
||||
@@ -138,8 +138,6 @@ def write_note(parent, event: dict, voice: str, divisions: int, tuplets: list[di
|
||||
element(item, 'octave', pitch['octave'] if pitch else 4)
|
||||
if not event.get('grace'):
|
||||
element(node, 'duration', int(fraction(pitch['duration'] if pitch else event['duration']) * divisions))
|
||||
for marker in (pitch or {}).get('sound_ties', []):
|
||||
element(node, 'tie', type=marker['type'], time_only=','.join(map(str, marker['passes'])) if marker.get('passes') else None)
|
||||
for field, action in (('tie_from', 'stop'), ('tie_to', 'start')):
|
||||
if pitch and pitch.get(field):
|
||||
element(node, 'tie', type=action)
|
||||
@@ -172,8 +170,6 @@ def write_note(parent, event: dict, voice: str, divisions: int, tuplets: list[di
|
||||
for beam in event.get('beams', []):
|
||||
element(node, 'beam', beam['type'], number=beam['level'])
|
||||
notations = element(node, 'notations')
|
||||
for action in (pitch or {}).get('printed_ties', []):
|
||||
element(notations, 'tied', type=action)
|
||||
for field, action in (('tie_from', 'stop'), ('tie_to', 'start')):
|
||||
if pitch and pitch.get(field):
|
||||
element(notations, 'tied', type=action)
|
||||
@@ -207,14 +203,10 @@ def write_note(parent, event: dict, voice: str, divisions: int, tuplets: list[di
|
||||
element(lyric, syllable['kind'], syllable['text'], **syllable['attributes'])
|
||||
|
||||
def write_barline(bar, measure, location):
|
||||
if not any(location in measure.get(field, {}) for field in ('barlines', 'repeats', 'endings')):
|
||||
if location not in measure.get('barlines', {}):
|
||||
return
|
||||
node = element(bar, 'barline', location=location)
|
||||
element(node, 'bar-style', measure.get('barlines', {}).get(location, 'regular'))
|
||||
if ending := measure.get('endings', {}).get(location):
|
||||
element(node, 'ending', ending.get('text', ''), number=','.join(map(str, ending['numbers'])), type=ending['type'], print_object='yes' if ending.get('visible', True) else 'no')
|
||||
if repeat := measure.get('repeats', {}).get(location):
|
||||
element(node, 'repeat', direction=repeat['direction'], times=repeat.get('times'))
|
||||
|
||||
def musicxml_tree(document: dict) -> ElementTree.ElementTree:
|
||||
validate_document(document)
|
||||
|
||||
Reference in New Issue
Block a user