Create a repeat section in LilyPond readable format.
rp(phrase, n = 1)
pct(phrase, n = 1, counter = FALSE, step = 1, reset = TRUE)
volta(phrase, n = 1, endings = NULL, silent = FALSE)
a phrase object or equivalent string to be repeated.
integer, number of repeats of phrase
(one less than the total
number of plays).
logical, if TRUE
, print the percent repeat counter above the
staff, applies only to measure repeats of more than two repeats (n
> 2).
integer, print the measure percent repeat counter above the
staff only at every step
measures when counter = TRUE
.
logical, percent repeat counter
and step
settings are only
applied to the single pct()
call and are reset afterward. If
reset = FALSE
, the settings are left open to apply to any subsequent
percent repeat sections in a track.
a single phrase or a list of phrases, alternate endings.
if TRUE
, no text will be printed above the staff at the
beginning of a volta section. See details.
a phrase.
These functions wraps a phrase object or a character string in LilyPond
repeat syntax. The most basic is rp()
for basic wrapping a LilyPond
unfold
repeat tag around a phrase. This repeats the phrase n
times, but
it is displayed in the engraved sheet music fully written out as a literal
propagation of the phrase with no repeat notation used to reduce redundant
presentation. The next is pct()
, which wraps a percent()
repeat tag
around a phrase. This is displayed in sheet music as percent repeat notation
whose specific notation changes based on the length of the repeated section
of music, used for beats or whole measures. volta()
wraps a phrase in a
volta()
repeat tag, used for long repeats of one or more full measures or
bars of music, optionally with alternate endings.
Note that basic strings should still be interpretable as a valid musical
phrase by LilyPond and such strings will be coerced to the phrase class by
these functions. For example, a one-measure rest, "r1"
, does not need to be
a phrase object to work with these functions, nor does any other character
string explicitly written out in valid LilyPond syntax. As always, see the
LilyPond documentation if you are not familiar with LilyPond syntax.
VOLTA REPEAT: When silent = TRUE
there is no indication of the number
of plays above the staff at the start of the volta section. This otherwise
happens automatically when the number of repeats is greater than one and no
alternate endings are included (which are already numbered).
This override creates ambiguity on its own, but is important to use multiple
staves are present and another staff already displays the text regarding the
number or plays. This prevents printing the same text above every staff.
PERCENT REPEAT: As indicated in the parameter descriptions, the arguments
counter
and step
only apply to full measures or bars of music.
It does not apply to shorter beats that are repeated using pct()
.
x <- phrase("c ec'g' ec'g'", "4 4 2", "5 432 432")
e1 <- phrase("a", 1, 5) # ending 1
e2 <- phrase("b", 1, 5) # ending 2
rp(x) # simple unfolded repeat, one repeat or two plays
#> <Musical phrase>
#> \repeat unfold 2 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 }
#>
rp(x, 3) # three repeats or four plays
#> <Musical phrase>
#> \repeat unfold 4 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 }
#>
pct(x) # one repeat or two plays
#> <Musical phrase>
#> \repeat percent 2 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 }
#>
pct(x, 9, TRUE, 5) # 10 plays, add counter every 5 steps
#> <Musical phrase>
#> \set countPercentRepeats = ##t
#> \set repeatCountVisibility = #(every-nth-repeat-count-visible 5)
#> \repeat percent 10 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 }
#> \set countPercentRepeats = ##f
#> \set repeatCountVisibility = #(every-nth-repeat-count-visible 1)
#>
pct(x, 9, TRUE, 5, FALSE) # as above, but do not reset counter settings
#> <Musical phrase>
#> \set countPercentRepeats = ##t
#> \set repeatCountVisibility = #(every-nth-repeat-count-visible 5)
#> \repeat percent 10 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 }
#>
volta(x) # one repeat or two plays
#> <Musical phrase>
#> \repeat volta 2 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 | }
#>
volta(x, 1, list(e1, e2)) # one repeat with alternate ending
#> <Musical phrase>
#> \repeat volta 2 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 | }
#> \alternative {
#> { <a\5>1 | }
#> { <b\5>1 | }
#> }
volta(x, 4, list(e1, e2)) # multiple repeats with only one alternate ending
#> <Musical phrase>
#> \repeat volta 5 { <c\5>4 <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 | }
#> \alternative {
#> { <a\5>1 | }
#> { <b\5>1 | }
#> }
volta(x, 4) # no alternates, more than one repeat
#> <Musical phrase>
#> \repeat volta 5 { <c\5>4^"Play 5 times." <e\4 c'\3 g'\2>4 <e\4 c'\3 g'\2>2 | }
#>