Automatic Repeats Detection with Custom Endings
I wish MuseScore had a feature for detecting automatically repeating segments, and compacting notation by using the proper vertical bars, along with the necessary 1. and 2. voltas for custom endings, when needed. I've worked to a patch (attached to this Issue) for realizing such a feature, that currently works on some simple scores I'm playing with, effectively reducing their size on screen and on paper when printed.
It had all started by checking whether this could have been written as a plugin
but it turned out that it was not possible, so I've produced a patch to the code, realizing a new "Edit -> Repeat Detector" menu entry that activates the feature.
Pictures of the result of applying this feature on a simple test-case can be found at:
-) it detects perfectly repeating contiguous whole measures;
-) if the repetition slightly differs for a few measures at the end, then the usual 1. and 2. voltas are used to denote the needed variations on the first and second play;
-) two options are used to control the behavior:
-) min_repeat_len is the minimum length (in measures) of a repeating segment;
-) max_volta_len is the maximum length (in measures) of the different part at the repeating segment end (the different 1. and 2. variations are covered by voltas);
-) these parameters might be set in a dialog popping up when activating this feature, so that the user can fine-tune them (unimplemented yet, but planned).
-) comparison of measures is based on their XML export, where the measure time (tick) has been properly shifted so that two identical measures in different parts of the score have the same identical XML; some times measures embed slight differences that are not visible on the screen (this happens even when editing very simple scores with MuseScore), and this causes the algorithm to not recognize them as identical;
-) complexity is cubic in the number of measures in the score (lots of improvement would be possible, but this already fits my trivial needs -- I hope).
Please, provide some feedback, thanks.