Skip to content
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

Merged
merged 5 commits into from
Nov 5, 2024
Merged

Cross staff voices #397

merged 5 commits into from
Nov 5, 2024

Conversation

fosfrancesco
Copy link
Member

@fosfrancesco fosfrancesco commented Oct 30, 2024

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:

  1. Corrected the MEI default example. The previous one had a wrong staff definition due to a conversion bug from musicxml
  2. Added file existence check in the MeiParser initialization to prevent errors when the file is not found.
  3. Modified the MEI import to import voices and staff numbers as specified in the score. The previous behavior was to create the number sequentially while going through parts, but this is prone to many problems, and doesn't allow handling cross staff voices.
  4. Modified _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.
  5. Enhanced merge_parts function to support a new auto option for reassigning staff and voice numbers, ensuring unique mappings according to MusicXML practice of 4 voices per staff.
  6. Updated tests to reflect these changes.
  7. Added a test for merge_parts with the auto option.
  8. Added tests for MusicXML and MEI cross staff import.

@sildater sildater mentioned this pull request Oct 31, 2024
@@ -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"]
Copy link
Member

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.

Copy link
Member Author

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 Show resolved Hide resolved
@@ -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
Copy link
Member

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

Copy link
Member Author

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

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Member Author

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

@fosfrancesco
Copy link
Member Author

Made some corrections following the reviewer suggestions

Copy link
Member

@manoskary manoskary left a 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.

@manoskary manoskary merged commit 94b0566 into develop Nov 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants