johentsch / ms3

A parser for annotated MuseScore 3 files.
https://ms3.readthedocs.io
GNU General Public License v3.0
41 stars 3 forks source link

Excerpts allowing for mc_onset positions [FEATURE] #94

Open johentsch opened 1 year ago

johentsch commented 1 year ago

Is your feature request related to a problem? Please describe. Currently (v2.1.1) excerpts can only be created to include entire MC units. It would be great to be able to

Describe the solution you'd like

Additional optional arguments start_mc_onset and end_mc_onset for the bs4_parser.Excerpt class which can be any number, most typically a Fraction.

For the start_mc_onset, it is not trivial to remove XML elements while maintaining correct positions of the remaining ones (can be done but much more convoluted because positions are relative and implicit). So the easiest solution might be to replace all note events before the given onset with rests. It remains to be seen how we would deal with the remaining score elements (harmony labels, dynamic marks, staff text, etc.). One solution might lie in making them invisible.

In terms of the end_mc_onset, the ideal solution would be if we could emulate the functionality in MuseScore that lets you select a measure and set the "Actual duration" in the Measure Properties to the desired value, which correctly truncates it (although it removes existing notes overlapping the new end of the bar rather than shortening them). In principle, it should be unproblematic to remove events after a given point because it does not affect any relevant positions. But for consistency we might as well use the same mechanism as for the start_mc_onset (replace notes with rests), which also would be adventageous for the following consideration.

In both cases we should decide how to deal with overlapping note events, which may, or may not, lead to more "organic" excerpts, e.g. by

This should probably become a boolean argument keep_overlapping to let the user decide.

Mechanics, avenues, pointers

Future

Suggestion to keep the high-level interface in score.py (to be added later) simpler by restricting the mechanism to mc_onset values, too, as opposed to alternatively allowing for mn_onset.