Skip to content

Commit

Permalink
Add a warning when tuplet.start_note.voice != tuplet.end_note.voice
Browse files Browse the repository at this point in the history
  • Loading branch information
leleogere committed Jan 28, 2025
1 parent e204c08 commit 540c668
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions partitura/io/importmusicxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,19 @@ def handle_tuplets(notations, ongoing, note):
assert (
start_tuplet.start_note.start.t <= stop_tuplet.end_note.start.t
), "Tuplet start time is after tuplet stop time"

# check that tuplets start and end notes belong to the same voice
for tuplet in starting_tuplets + stopping_tuplets:
if (
tuplet.start_note is not None
and tuplet.end_note is not None
and (tuplet.start_note.voice != tuplet.end_note.voice)
):
warnings.warn(
f"Tuplet start and end notes do not belong to the same voice "
f"({tuplet.start_note.voice} != {tuplet.end_note.voice}). This might "
f'indicate a missing <tuplet type="start"> or <tuplet type="stop">.'
)
return starting_tuplets, stopping_tuplets


Expand Down

0 comments on commit 540c668

Please sign in to comment.