Helper functions for concatenating musical phrases and other strings
together as well as repetition.
The functions pc
and pn
are based on base functions
paste
andrep
, respectively, but are tailored for efficiency in
creating musical phrases.
pc(...)pn(x, n = 1)
character, phrase or non-phrase string.
character, phrase or non-phrase string.
integer, number of repetitions.
phrase on non-phrase character string, noteworthy string if applicable.
These functions respect and retain the phrase class when applied to phrases. They are aggressive for phrases and secondarily for noteworthy strings. Combining a phrase with a non-phrase string will assume compatibility and result in a new phrase object. If no phrase objects are present, the presence of any noteworthy string will in turn attempt to force conversion of all strings to noteworthy strings. The aggressiveness provides convenience, but is counter to expected coercion rules. It is up to the user to ensure all inputs can be forced into the more specific child class.
This is especially useful for repeated instances. This function applies to general slur notation as well. Multiple input formats are allowed. Total number of note durations must be even because all slurs require start and stop points.
# NOT RUN {
pc(8, "16-", "8^")
pn(1, 2)
x <- phrase("c ec'g' ec'g'", "4 4 2", "5 432 432")
y <- phrase("a", 1, 5)
pc(x, y)
pc(x, pn(y, 2))
pc(x, "r1") # add a simple rest instance
class(pc(x, y))
class(pn(y, 2))
class(pc(x, "r1"))
class(pn("r1", 2))
class(pc("r1", "r4"))
# }
Run the code above in your browser using DataLab