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

@@ -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
@huispaty huispaty deleted the cross_staff_voices branch February 13, 2025 13:13
manoskary added a commit that referenced this pull request Feb 27, 2025
PR for Version 1.6.0.

The following changes were applied:

# Updated Merge Report

below the updated notes for this PR to include most recent changes

## PR for version 1.6.0

This new version addresses multiple changes, bug fixes and new features:

### New features
- Measure refactor for musicxml, match, midi, note array to part in #376
- Measure feature #377
- Clef feature #382
- Clef map #384 #396
- Stem direction #392 
- Support for cross staff voices in mei #397
- Improved parsing of Kern scores #413 
- Fixed import for performance pedal #399 
- Tick Units are now supported for pianoroll creation #412 
- Scores can be loaded directly for URL #404 
- Support for invisible objects in musicxml import #401 
- Support for Fingering annotations in MusicXML and MEI import/export #403 

### Bug fixes
- Corrected `get_time_maps_from_alignment` #360
- Corrected metrical strength features #364
- Corrected offsets for tied notes #366
- Fixed import issue #368
- Fixed Kern parsing #370
- Duration of Chord Notes #418 
- Corrected symbolic note duration #372
- Fixed tuplet bug #387
- Addressed sorting for enharmonic notes #407 
-  Fixes eq bug on performed notes #422
- Fixed timing-tempo change bug #427 

### Other Changes
- Added check for empty note array #361
- Improved documentation #362 #364
- Removed default voice estimation #373
- Added warning #379 
- Removed ordering in musicxml export #391
- Improved Fingering parsing in MusicXML that could result to errors #416
- Replaced Deprecated Scipy Function #417 
- Improved support for input and export in musicxml tuplet object
- New option to force add new segments #410
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