Helper functions for indexing and moving notes within noteworthy strings.
note_slice(notes, ...)note_rotate(notes, n = 0)
note_shift(notes, n = 0)
note_arpeggiate(notes, n = 0, ...)
character, a noteworthy string, space-delimited or vector of individual entries.
For note_slice
, an integer or logical vector. See details.
For note_arpeggiate
, additional arguments to transpose
,
specifically key
and style
.
integer, degree of rotation.
character
note_slice
subsets the timesteps of a noteworthy string by integer
index or logical vector of length equal to the number of timesteps.
note_rotate
simply rotates anything space-delimited or vectorized in
place. It allows chords. Octave numbering is ignored if present.
For note_shift
the entire sequence is shifted up or down, as if
inverting a broken chord.
In this case notes
is strictly interpreted and may not include chords.
Octave numbering applies, though large multi-octave gaps will be condensed
in the process.
Given the context of note_shift
, the notes
sequence should be
ordered by increasing pitch.
If it is not, ordering will be forced with each inversion during the
n
shifts.
note_arpeggiate
also allows notes only. It is similar to
note_shift
, except that instead of a moving window,
it grows from the original set of notes by n
in the direction of the
sign of n
.
# NOT RUN {
x <- "e_2 a_, c#f#a#"
note_slice(x, 2:3)
note_slice(x, c(FALSE, TRUE, TRUE))
note_rotate(x, 1)
note_shift("c e g", 1)
note_shift("c e g", -4)
note_arpeggiate("c e g", 5)
note_arpeggiate("c e g", -5)
# }
Run the code above in your browser using DataLab