append_phrases: Concatenate and repeat

append_phrasesR Documentation

Concatenate and repeat

Description

Helper functions for concatenating musical phrases and raw strings together as well as repetition.

Usage

pc(...)

pn(x, n = 1)

Arguments

...

character, phrase or non-phrase string.

x

character, phrase or non-phrase string.

n

integer, number of repetitions.

Details

Note: When working with special tabr classes, you can simply use generics like c() and rep() as many custom methods exist for these classes. The additional respective helper functions, pc() and pn(), are more specifically for phrase objects and when you are still working with character strings, yet to be converted to a phrase object (numbers not yet in string form are allowed). See examples.

The functions pc() and pn() are based on base functions paste() and rep(), respectively, but are tailored for efficiency in creating musical phrases.

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.

Value

phrase on non-phrase character string, noteworthy string if applicable.

Examples

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"))

tabr documentation built on Sept. 12, 2024, 6:18 a.m.