Skip to main content

Repeats and structural elements

Repeats, jumps, and section markers drive how a score reads across systems. alphaTab picks them up from the source file and renders each with its standard engraving convention.

Simple repeatsโ€‹

Repeat barlines are the thick double bars with a dot pattern that tell the player to replay a passage. When the passage repeats more than twice, alphaTab draws the count above the closing barline so the reader knows how many times through โ€” the standard way to notate the four-bar chorus that plays three times.

Alternate endingsโ€‹

Alternate endings are the numbered brackets above a repeated section that select a different bar on each pass โ€” the "first time, second time" convention used at the tail of every verse-chorus form. Each ending's numeric label indicates which pass through the repeat plays that bar.

D.C. and D.S.โ€‹

Da capo (D.C.) and dal segno (D.S.) directions are the "back to the top" and "back to the segno" jump instructions that keep long forms readable without physically repeating bars. alphaTab renders them as text labels above the target barline and honors D.C., D.C. al Fine, D.C. al Coda, D.S., D.S. al Fine, and D.S. al Coda from the source file.

Segno and codaโ€‹

Segno and coda are the target glyphs the D.S. and al Coda directions jump to โ€” the segno paired with D.S., the coda paired with al Coda on the second pass. alphaTab renders both as the standard SMuFL glyphs above the staff at their target bars, and draws Fine as text.

Section markersโ€‹

Section markers are the labeled text tags above a bar that name a formal section โ€” Intro, Verse, Chorus, Bridge. alphaTab renders them above the staff at the marked bar, drawn from the marker text in the source file.

Playback order (new in 1.9)โ€‹

The player, the cursor and MIDI export follow repeats, alternate endings and jumps in the same order. Since 1.9.0 these rules apply:

  • Each D.C. and D.S. direction is taken once. When playback reaches it a second time, it continues with the next bar.
  • After a jump, repeats play as their final pass: the passage plays once, and of its alternate endings only the last one, the same way MuseScore plays it.
  • Repeat passes are counted per repeat group. A repeat sign in several alternate endings plays every ending once, as in Guitar Pro 8.
  • A jump inside a repeat, or on its closing bar, is taken on the final pass, after all repeats have played, as in Guitar Pro 8 and MuseScore.
  • A jump on an alternate ending that playback skips is not taken.
  • MusicXML files that write D.C., D.S., To Coda, Coda, Segno and Fine as attributes of a <sound> element inside a <direction> (the way MuseScore exports them) play these jumps instead of only showing the text.

Press play in the next demo and follow the cursor. Bar 1 opens a repeat, bars 2 and 3 are the first and second ending, bar 3 carries Fine, and bar 4 ends with D.C. al Fine. The playback order is bars 1 2 1 3 4 1 3: after the D.C. the repeat plays as its final pass, so bar 1 continues straight into the second ending, where Fine ends the piece.

00:00
00:00
\track "Guitar"
\staff {score}
\ro :4 C4 D4 E4 F4 |
\ae 1 \rc 2 G4 F4 E4 D4 |
\ae 2 \jump fine G4 E4 :2 C4 |
\jump daCapoAlFine :4 A4 G4 F4 E4

In the next demo D.C. al Coda sits on the closing bar of a repeat. It is taken after the repeat has played, and the second time through To Coda jumps to the coda. The playback order is bars 1 2 3 1 2 3 1 2 4.

00:00
00:00
\track "Guitar" { defaultSystemsLayout 3 }
\staff {score}
\ro :4 C4 D4 E4 F4 |
\jump daCoda G4 A4 B4 C5 |
\rc 2 \jump daCapoAlCoda C5 B4 A4 G4 |
\jump coda :2 C4 C4

In alphaTex, repeats and jumps are written with the bar metadata \ro, \rc, \ae and \jump.

Show it in codeโ€‹

Every structural element above is on by default. To hide one category โ€” for example, section markers in a compact printout โ€” set its notation.elements entry to false:

import * as alphaTab from '@coderline/alphatab';

const container = getAlphaTabContainer();
const api = new alphaTab.AlphaTabApi(container, {
core: { file: '/scores/song.gp' },
notation: {
elements: new Map([
[alphaTab.NotationElement.EffectMarker, false],
[alphaTab.NotationElement.EffectDirections, false],
[alphaTab.NotationElement.RepeatCount, false],
]),
},
});

getAlphaTabContainer() is a placeholder for the platform-specific render target. See NotationElement for every togglable category.

Where to look nextโ€‹