Learn R Programming

tabr (version 0.1.2)

append_phrases: Append and duplicate

Description

Helper functions for appending or pasting musical phrases and other strings together as well as repetition. The functions glue and dup are based on base functions paste andrep, respectively, but are tailored for efficiency in creating musical phrases. These functions respect and retain the phrase class when applied to phrases. Combining a phrase with a non-phrase string will assume compatibility and result in a new phrase object.

Usage

glue(...)

dup(x, n = 1)

Arguments

...

character, phrase or non-phrase string.

x

character, phrase or non-phrase string.

n

integer, number of repetitions.

Value

phrase on non-phrase character string.

Details

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.

Examples

Run this code
# NOT RUN {
glue(8, "16-", "8^")
dup(1, 2)
x <- phrase("c ec'g' ec'g'", "4 4 2", "5 432 432")
y <- phrase("a", 1, 5)
glue(x, y)
glue(x, dup(y, 2))
glue(x, "r1") # add a simple rest instance
class(glue(x, y))
class(dup(y, 2))
class(glue(x, "r1"))
class(dup("r1", 2))
class(glue("r1", "r4"))
# }

Run the code above in your browser using DataLab