Improve the staff hiding algorithm to allow custom control and bottom alignment

• Aug 13, 2019 - 09:43
Reported version
S5 - Suggestion

Steps to reproducethe issue:
1) Create a full orchestral score that occupies the whole page
2) Select the "Hide empty staves within systems" option from the Format / Style / Score menu
3) Enter some notes on slightly more than half the total number of staves on enough measures to reach two or more pages.
4) The empty staves on the second page will be hidden, causing the system to occupy lss than the available space but slightly more than half page. Hence, a large blank space will be left below the system.
5) If the number of hidden staves on different pages is different, the blank space will be of variable height.

(This issue originated in the following forum discussion:
The "hide empty staves within systems" feature is very handy to save space and to allow more music to be included on each page, if that is possible. However, as the feature is currently implemented, it causes potential blank spaces at the bottom of pages and, to make matters worse, these blank spaces may present different heights causing an uneven presentation. The way the leading publishing houses solve this involves two steps: 1) Selectively unhiding some empty staves and 2) adjusting the staff distance so that the last staff is flush with the botom margin.
Step 1 usually follows some criteria such as unhiding empty staves that were not empty in the previous system or will not be empty in the next one, or unhiding groups of related instruments such as French horns, woodwinds, etc. Besides, there is always room for custom selection according to the engraver's criterion and experience.
Step 2 is attained by distributing the space that would remain between the lower staff and the bottom margin into the staff space between consecutive staves. This space will usually be quite small if after step 1 only a fraction of staff + staff space is left below the lower staff.

To allow MuseScore render scores according to the preceding considerations, two main changes are necessary:
1) There must be a way to unhide hidden staves. This may be partially automatic in order to get a reasonable first approximation, and partially manual to allow fine tuning of the general layout.
2) There must be a way to change the staff distance. Currently this is fixed and can only be changed automtically by the autoplacement algorithm in certain cases and manually through spacers. One way would be to replace the Systen distance setting (from the Format / Style / Score dialog) with a minimum and a maximum value

Taking these changes for granted, there are two situations: automatic and manual empty staff hiding / unhiding.

Automatic algorithm proposal
Assuming that Hide empty staves within system has been checked, the following proceeds sequentially starting on page 2. Page 1 usually shows all the staves, regardless of being empty or not, but if not, start on page 1
1) If after hiding empty staves a page has a blank below the last system that is smaller than 20 % of the page (or other suitable percentage, which could be a preference), then stretch the space between staves so that the last staff is aligned with the bottom margin.
2) If it is larger than 20 %, unhide some staves according to the following rules:
a) For each empty staff check if in the previous system it was unhidden; if so count the number of empty measures in that staff at the end of the last system, taking inf (infinite) or a very large number if the complete staff was also empty. Assign that number to an index Ai where i is the number of staff. If no previous system, set Ai = inf.
b) For each empty staff check if in the next system it is not empty; if so, count the number of empty measures in that staff at the beginning of the next system and assign it to an index Bi. If no next system, set Bi = inf
c) Define Ci as the minimum between Ai and Bi.
d) Unhide the empty staves starting from the one with the smaller Ci (i.e., the one having closer non-empty measures). If there are more than one with the same Ci, prefer those staves corresponding to bowed instruments, then brass, then woodwinds, then percussion. NOTE: The order of preference could also be an option
e) Keep unhiding staves until condition 1) is fulfilled and proceed as indicated there.

Manual hide/unhide mangement
The proposal is to add two new items to the contextual menu that opens when right-clicking on an empty part of a staff:
1) Hide / Unhide empty staves in this system, which would be similar to the Format / Style / Score corresponding preference, but more readily accessible and within the compass of the current system only. The typical use is to turn all staves visible to allow selecting which one is to be kept visible in spite of being empty.
2) Hide/Unhide this staff if empty. When Hide is selected, a flag is activated allowing the global setting to take control, so when 1) is activated, the staff in the current system will be hidden if empty. When Unhide is selected, the flag is cleared and the current staff in the current system wil remain visible overriding the global setting.

Staff distance can be increased using spacers. They can be selected in group and their height changed at once from the inspector.
A staff can be unhidden adding an invisible voice with disabled playback.


UPDATE: The proposed workaround isn't practical indeed, since adding a note in a fake second voice and making it invisible and not playable requires many steps (one of them scrolling the inspector) so it is too cumbersome if several staves must be unhidden. Besides, in order to know when the unhiding process is complete one has to manually calculate the required number of unhidden staves. Trial and error is not possible since toggling between hiding or not empty staves takes much time for large scores.
One possible workaround for this problem is to copy and paste the fake note.

One possible workaround for this problem is to copy and paste the fake note

This is my primary method of unhiding individual staves though you have to watch for creating accidentals (which become visible) in the staves you are pasting. Another issue is getting to the staff you want to unhide. If it's not the next staff you want to unhide, you need to count carefully to make sure you select the correct instrument to unhide.

In reply to by mike320

What I'm doing is to estimate how many unhidden empty staves I will need so that after adding spacers to align to bottom the page doesn't look too sparse, unhide all from the Format / Style box (it takes several seconds), add the fake notes to the empty staves I want to keep visible (I choose them following a priority order). Finally I add the spacers (see
I haven't experienced the accidental problem, I suppose it appears in the case of transposing instruments and could be fixed moving that particular note.

Workaround Yes No

Using the invisible note is not a good workaround. It removes the ability of merging the pauses into a multi measure pause in the parts. We need a workaround, that only affects one part (e.g. the main part) and not the whole project. Open for suggestions for this kind of workaround, I couldn't figure something out.

In reply to by Jojo-Schmitz

I think it should only be called workaround if it does not create other problems, that don't have a workaround (what is clearly the case). There is obviously for everything a workaround (in this case maintain multiply projects) or position every last bit your self for some formatting issues but there is a point at which it should not be called workaround anymore.

So bottom line: the current workaround raises new issues without a workaround. Therefore, there is no known way to reproduce (work around) the requested feature with already implemented features in the program.

The workaround I use:

  • Add a Staff Text to the measure in the system you want to hide
  • Color this text completely transparent (zero alpha).

That's it, and I like that it can be copied and pasted around (or Repeated).
I use this mainly for cutaway scores but can be used to unhide whole staves.

And you can even use these as spacers and give them a fancy tool look. In the second example below I edited the text to this icon from Wingdings and moved it up - since it is set to Automatic Placement, it forces the spacing to the previous staff.

visible things.png

In addition, you can CTRL-SHIFT- drag this text to your favorite palette and it becomes a MuseScore tool ;)
The only caveat is that the icon is shown invisible also in the palette, but nothing's perfect.

Attachment Size
visible things.png 8.13 KB