Multi-bar rests
Collapse runs of empty (or rest-only) bars into a single multi-bar rest glyph with a count above it โ the traditional big-band notation for a horn section that sits out for eight bars, or a sight-reader's cue for how long an educational score's empty stretch runs. Ensemble parts get shorter, sight-readers get a clearer count, and the layout algorithm has fewer bars to squeeze onto each row.
Score-wide vs cherry-pickingโ
Two fields on score.stylesheet control the feature:
multiTrackMultiBarRestโ a boolean. Whentrueand multiple tracks are rendered together, subsequent bars that are empty on every rendered track collapse into one multi-bar rest.perTrackMultiBarRestโ aSet<number>of track indexes. Add a track'sindexto opt it in. When it isnull(default), the score-wide rules apply as-is; when it holds indexes, only those tracks participate in multi-bar-rest collapsing.
The two work together. In a full-band render, multiTrackMultiBarRest = true collapses empty regions across the band. If you're rendering a subset โ a solo transcription of the bass line โ populate perTrackMultiBarRest with the track index to get the same behavior on a single-track render.
Related empty-staff controlsโ
If your goal is not to compress rests but to hide a track when it has nothing to say for a while, two adjacent flags do that instead:
hideEmptyStavesโ hides staves whose entire content in a system is empty.hideEmptyStavesInFirstSystemโ extends the same behavior to the first system, which normally stays visible so the reader sees every part at least once.
These are independent from the multi-bar-rest flags and can be combined.
Show it in codeโ
import * as alphaTab from '@coderline/alphatab';
const container = getAlphaTabContainer();
const api = new alphaTab.AlphaTabApi(container, {
core: { file: '/scores/song.gp' },
});
api.scoreLoaded.on((score) => {
// Enable it band-wide:
score.stylesheet.multiTrackMultiBarRest = true;
// Or cherry-pick which tracks participate:
score.stylesheet.perTrackMultiBarRest = new Set(
score.tracks.filter((t) => t.name.includes('Bass')).map((t) => t.index)
);
api.render();
});
getAlphaTabContainer() is a placeholder for the platform-specific step of obtaining the render target โ a <div> on Web, an AlphaTab control on .NET, or an AlphaTabView on Android. Every other line runs unchanged on all three runtimes.
Where to look nextโ
- Bracket extend mode โ how the accolade bracket handles hidden or collapsed staves.
- Track name policies โ labeling behavior around hidden staves.
- Repeats and structural elements โ the counted glyph pairs with repeat structures on ensemble parts.
multiTrackMultiBarRestandperTrackMultiBarReston theRenderStylesheetreference.scoreLoadedandrenderโ the API surface used above.