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

'Fine' marking in final volta of a repeat handled incorrectly #116

Open mattblessing opened 1 month ago

mattblessing commented 1 month ago

Describe the issue Hi there,

I was using 'ms3 extract [...] -M [...]' to obtain a score's measure information. The score has a 'D.C. al Fine' marking at the end and the 'Fine' marking is at the final volta of a particular repeat. The score's playback in MuseScore is as follows: once 'D.C. al Fine' is reached, the score is played again from the beginning, and instead of playing the repeats normally it skips to the final volta of each repeat. Therefore, this final volta marked with 'Fine' is played twice.

I was expecting the measure information to have "next": [..., -1] for this measure, but instead it had "next": [-1] due to lines 935-940 of 'bs4_measures.py':

volta_mcs = dict(df.loc[df.volta.notna(), ["mc", "volta"]].values)
if fine_mc in volta_mcs:
    # voltas can be reached only a single time, hence the name
    self.next[fine_mc] = [-1]
else:
    self.next[fine_mc].append(-1)

I should also note that the score originally (incorrectly) had the 'Fine' marking at the first volta of the repeat, and because this measure isn't even played a second time, the 'Fine' marking was ignored and this resulted in no measures having "next": [..., -1].

I overcame this bug by simply replacing the above lines with 'self.next[fine_mc].append(-1)' because it is evident that voltas can be played more than once when there are markings like 'D.C. al Fine'. However, it may also be valuable to check if a 'Fine' marking is ignored and produce some kind of warning to the user if this is the case.

ms3 version 2.5.1

To Reproduce This can be reproduced by executing 'ms3 extract [...] -M [...]' on a score with 'D.C. al Fine' at the end and 'Fine' at a volta in the score.

Thanks a lot!