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

Helpful messaging when updating instrumentation #81

Closed johentsch closed 1 year ago

johentsch commented 1 year ago

Working example

Let us consider a score that includes a part with two staves. The columns staff_1_instrument and staff_2_instrument in the metadata.tsv have the value "Piano": handel_test.zip

Current behaviour

With the latest version, updating the column staff_1_instrument (here with "Drumset") results in the warning

INCONSISTENT_INSTRUMENT_CHANGE_WITHIN_PART (31,) ms3.Parse.handel_keyboard.hwv430d_Grobschmied_Aria -- ~/ms3/src/ms3/bs4_parser.py (line 2194) set_instrument():
    The change of staff_1 to drumset will also affect staves ['staff_2'] with instruments: 
    {'staff_2': 'piano'}

Updating both columns with different instruments (here with "Flute" and "Accordion") yields

INCONSISTENT_INSTRUMENT_CHANGE_WITHIN_PART (31,) ms3.Parse.handel_keyboard.hwv430d_Grobschmied_Var1 -- ~/ms3/src/ms3/bs4_parser.py (line 2194) set_instrument():
    The change of staff_1 to flute will also affect staves ['staff_2'] with instruments: 
    {'staff_2': 'piano'}
INCONSISTENT_INSTRUMENT_CHANGE_WITHIN_PART (31,) ms3.Parse.handel_keyboard.hwv430d_Grobschmied_Var1 -- ~/ms3/src/ms3/bs4_parser.py (line 2194) set_instrument():
    The change of staff_2 to accordion will also affect staves ['staff_1'] with instruments: 
    {'staff_1': 'flute'}

Desired behaviour

In the first case, changing only one instrument, the error is "less bad" because the user might have just been lazy, knowingly changing only one hand. That's perfectly fine.

It's different in the second case where they, apparently, wanted to assign two different instruments to both hands -- which MuseScore does not allow. The error message should be slightly more elaborate in this case, maybe something like:

INCONSISTENT_INSTRUMENT_CHANGE_WITHIN_PART (31,) ms3.Parse.handel_keyboard.hwv430d_Grobschmied_Aria -- ~/ms3/src/ms3/bs4_parser.py (line 2194) set_instrument():
    You are trying to assign instruments {staff_1: "Flute", staff_2: "Accordion"} but they are belonging to the same part.
    In order to assign two different instruments, you would have to split them in two parts in MuseScore.
    For now, I'm assigning "Flute" to all of them.

Note that contrary to the current behaviour, this is picking the value for the first staff, Flute, not the last one (the warnings above did not inform the user about the choice).