-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross staff voices #397
Cross staff voices #397
Conversation
…tion due to a musicxml conversion bug
…of musicxml, with 4 voices per staff
…n, and is able to correctly handle cross-staff voices
partitura/io/importmei.py
Outdated
@@ -322,11 +326,9 @@ def _handle_clef(self, element, position, part): | |||
# find the staff number | |||
parent = element.getparent() | |||
if parent.tag == self._ns_name("staffDef"): | |||
# number = parent.attrib["n"] | |||
number = 1 | |||
number = parent.attrib["n"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to get the tag as a dict but in case it is not there output 1 to avoid possible key errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should never happen, but I corrected it with a default value just in case
partitura/io/importmei.py
Outdated
@@ -982,7 +1010,7 @@ def _handle_staff_in_measure( | |||
for i_layer, layer_el in enumerate(layers_el): | |||
end_positions.append( | |||
self._handle_layer_in_staff_in_measure( | |||
layer_el, i_layer + 1, staff_ind, position, part | |||
layer_el, int(layer_el.attrib["n"]), staff_ind, position, part |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again about the potential keyerror
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected with default in case of wrong or incomplete MEI
partitura/io/importmei.py
Outdated
@@ -1063,7 +1091,7 @@ def _handle_section(self, section_el, parts, position: int, measure_number: int) | |||
for i_s, (part, staff_el) in enumerate(zip(parts, staves_el)): | |||
end_positions.append( | |||
self._handle_staff_in_measure( | |||
staff_el, i_s + 1, position, part, measure_number | |||
staff_el, int(staff_el.attrib["n"]), position, part, measure_number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected with default in case of wrong or incomplete MEI
…, to avoid parsing exceptions.
Made some corrections following the reviewer suggestions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces several enhancements and bug fixes related to cross-staff voices import and handling in Partitura, specifically for MEI files which until now have been handled slightly differently than MusicXML.
Summary of changes:
- Added a file existence check in the MeiParser initialization.
- Modified MEI import to handle voices and staff numbers as specified in the score.
- Updated various methods to manage cross-staff notes.
- Enhanced the merge_parts function to support unique mappings for staff and voice numbers.
- Corrected the MEI default example.
- Updated and added new tests to reflect these changes.
This pull request introduces several enhancements and bug fixes related to cross-staff voices import and handling in Partitura. The modifications involve in particular the MEI import.
Changes:
_handle_note
,_handle_rest
,_handle_mrest
,_handle_multirest
, and_handle_chord
,_handle_staff_in_measure
methods to handle different staff specifications for cross-staff notes and rests.auto
option for reassigning staff and voice numbers, ensuring unique mappings according to MusicXML practice of 4 voices per staff.merge_parts
with theauto
option.