Barlines...

• Apr 12, 2019 - 17:49

I promised Marc Sabatella that I would look at barlines, and I'm currently in the process of fulfilling that promise.

Background

I got so frustrated with the way lines worked in versions prior to 3.1-beta, that I closed the program and went back to using version 2.3.2, so if some of this worked the same prior to the beta release, I'm not aware of it. I tested this on existing scores, some and extensively on a score I created using the Classical Orchestra template in 3.1-beta.

Spanned barlines

I found a bug with barlines when they cross a staff with one line and submitted a bug report #287610: Percussion barlines disjointed when spanning multiple staves with one staff line..

I tried to adjust the span of barlines across staves and was initially not happy. It's impossible to double the bottom staff's barline and shorten to line more than one staff. Actually, you can't even do that. You have to double click the line for the staff above it, then you can shorten the line span by 1 staff. I initially found this to be more of the same #$%& I was getting in earlier 3.x version. I then did some more testing so I could write a reasonable bug report (which at this point has not happened..continue reading).

After further testing, I discovered you could double click any of the barlines extended below the staff and shorten it to so it no longer extends to the next staff. To my pleasant surprise, all of the staves above and all of the staves below were still connected by spanned barlines! I added an instrument above a group of connected staves and it was not connected as expected. I double clicked a barline and dragged it down part way. The result was that all of the staves above where I stopped were connected and all of the staves below were still connected. This is good.

Set as staff default
Using Set as staff default on multiple barlines does not work. I selected 2 measures on 2 consectutive staves. Removed the check from "Span to next staff" expecting all barlines in both staves to not span to the next, and I got mixed results. The first staff worked as expected. The second staff, only the first measure had the barline not span. See issues #287613: Set to staff default only affects first selected barline and #287614: Customized barline spans not always overriden when extending staff barline span.

Parts
My initial testing on parts indicates that barlines work between the main score and parts. I did various tests adding and deleting repeats, double barlines and dotted barlines.

My only question is the expected result when you add a dotted line to only one instrument that is connected to the next instrument. In my test I added it to Violin 1 in my classical orchestra score. The dotted line extended down to the next staff, but the next staff and all below it remained solid. I'm not sure of the expectation in this case.

Another bug
If you insert a double barline, in a score with the barlines connected, it works as expected. If you then add an instrument in the middle of these connected instruments (like an instrument between the clarinet and bassoon in the classical orchestra score), the double barline will connect all of the instruments, and the rest of the barlines will be disconnected from the new instrument to the instrument below it. See #287617: Double barlines span to next staff when instrument inserted

Conclusion
After testing, I see great improvements and no longer consider the barline problems to be a barrier to using version 3.1, though there are still some bugs that need fixed. I marked them all minor because most of them are probably corner cases. It would be convenient at times to be able to make more than one consecutive staff not have barlines connected to the next in one step. The real issue in this case is making the inspector work consistently.

As you can see, I was typing this as I was testing and did file a few bug reports after all.


Comments

Great, thanks for the update! I very much appreciate the feedback and hope to fix the issues you mention before release.

Currently, it is true that lengthening a barline to extend through multiple staves is easier than shortening. You can lengthen them in a single drag operation, but to shorten them you have to do it staff by staff. Before my fix, it worked similarly, except that you'd have to also update all double bars and other customized barlines individually - that's one of the things I fixed. I do still want to improve the barline-shortening experience further, but at least it is not too hard to get the desired result, and shortening barlines is not something that one typically does that often.

Regarding the bug you mention with adding an instrument between two connected instruments - it's obviously a bug that right now the double (and other modified) barlines connect, but the normal ones don't. But to me it's worth considering whether it would be better to have them all connected or go back to the 2.3.2 behavior of connecting none by default. I'm inclined to think it makes more sense to connect them all. In any case, it's but a single operation to change it which the default is.

In reply to by mike320

As far as the code is concerned, double and dotted are pretty equivalent, except with respect to multimeasure rests (double bars break them, dotted ones don't).

Repeats are totally different, though. Internally, these don't start life as barlines at all - instead it's a flag on the measure itself as to whether it starts a repeat, ends a repeat, or both. Then we figure out on the fly what kind of repeat barline to display, based on whether the measure is at the beginning, middle, or end of system. And since a measure spans all staves always, it's pretty unlikely you'll see bugs where repeat barlines display inconsistently from staff to staff.

BTW, I provide all this background info for a few reasons. One, so people testing have a sense of how things work that can help give insight into what corner cases might have been missed. Also, maybe it provides some ideas about the best way to accomplish some task. And finally, it's a way for me to record some information for the future to aid whoever might be trying to fix any bugs I don't get around to in the next couple of weeks. And that goes for me too - six months from now I'll likely forget a bunch of this stuff and will be happy to be able to reread this.

Something that may be of help to anyone trying to get a handle on how things work:

The big change between MuseScore 2 and MuseScore as it relates to barlines has to do with how we handle extending them between staves. Let's say you have an orchestra score with four connected woodwinds, three connected brass, and five connected strings.

In MuseScore 2, this was represented as a total of three barlines. The first attached to the flute with a span of 4, the second attached to the first horn part with a span of 3, and the third attached to the first violin with a span of 5. As far as MuseScore was concerned, the other instruments simply had no barlines at all.

This worked OK but led to quite a few bugs where behavior would be off if you then added or removed instruments or marked some invisible or used hide empty staves, or otherwise changed the makeup of instruments. The span counts would then be wrong and need to be corrected or else you'd end up with a barline extending from the winds to the brass, or the last instrument of a section would be orphaned, etc. Sometimes it would work at first but then be wrong on undo, etc. Over the years we managed to fix enough of these bugs so that by 2.3.2 it wasn't too bad, but quite a few remained even so. Also, if wanted to break a barline within a section (like separating the violins from the rest of the strings) this couldn't really be done directly but required multiple steps.

In MuseScore 3, a different internal representation is used. In the score described above, instead of some staves having barlines and others not, now each staff has a barline, period. Instead of each barline having a count of the number of staves it spans, it's each barline just records whether it spans to the next staff or not.

This instantly simplified a lot of things and allowed the removal of a fair amount of complicated code that didn't work all that well anyhow. However, the implementation of the new scheme was not as complete as it should have been, resulting in regressions that were by any measure worse than the problems fixed. That's unfortunate indeed. Luckily, the relatively simple nature of how things are represented internally did make fixing most of those problems not too hard.

What we're left with now is something that I think works pretty well overall, but no doubt there is still some cleanup to do.

In reply to by Marc Sabatella

So, that said:

The issue with the "Set as staff default" button in the Inspector only affecting one staff looks to be a simple fix, we are indeed literally only applying the action to the "current" element (the one whose values are actually displayed, in cases where values differ across the selection). In theory the fix is just to loop over the whole selection, probably skipping multiple barlines on the same staff.

Regarding the expected behavior when adding a dotted barline to a staff that is connected to the staff below: realizing that each staff has a barline and a flag to control whether it spans to the staff below, you can see that the portion of barline extending between staves "belong" to the staff above. So the most natural behavior given the implementation is, whatever style a barline has, the portion drawn below if spanned will be the same. I say "natural" but that's not the same as "desirable". Maybe more desirable is, we draw the extended portion of the barline between staves as normal unless both staves are modified. But then we'd still have to question how to draw it if both are modified differently. That is, how to draw the barline between staves if the upper is dotted and the lower dashed, or the upper double but the lower final, etc.

Do you still have an unanswered question? Please log in first to post your question.