Skip to content

Commit

Permalink
Merge pull request #316 from CPJKU/musicxml_import_fix
Browse files Browse the repository at this point in the history
pull-request solving a bug in musicxml import when the direction tag contains no elements
  • Loading branch information
fosfrancesco authored Sep 15, 2023
2 parents dd5b2ff + 32cf670 commit 03a88ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion partitura/io/importmusicxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,9 @@ def _handle_direction(e, position, part, ongoing):
# first child of direction-type is dynamics, there may be subsequent
# dynamics items, so we loop:
for child in direction_type:
# check if child has no children, in which case continue
# interpret as score.Direction, fall back to score.Words
dyn_el = next(iter(child))
dyn_el = next(iter(child), None)
if dyn_el is not None:
direction = DYN_DIRECTIONS.get(dyn_el.tag, score.Words)(
dyn_el.tag, staff=staff
Expand Down
8 changes: 8 additions & 0 deletions tests/data/musicxml/test_note_features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
<line>2</line>
</clef>
</attributes>
<direction placement="below">
<direction-type>
<dynamics>
</dynamics>
</direction-type>
<staff>1</staff>
<sound dynamics="100.00"/>
</direction>
<note default-x="80.72" default-y="-30.00">
<pitch>
<step>G</step>
Expand Down

0 comments on commit 03a88ef

Please sign in to comment.