Helper functions for indexing and moving notes within noteworthy strings.
note_slice(notes, ...)
note_sort(notes, decreasing = FALSE)
note_rotate(notes, n = 0)
note_shift(notes, n = 0)
note_arpeggiate(notes, n = 0, step = 12)
character, a noteworthy string, space-delimited or vector of individual entries.
For note_slice()
, an integer or logical vector.
logical, short in decreasing order.
integer, number of rotations or extensions of note sequence. See details.
integer, number of semitone steps from the first (or last) note
in notes
at which to begin repeating the shifted notes
sequence as an
arpeggio. See examples.
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_sort()
sorts the timesteps of a noteworthy string by pitch. When a tie
exists by root note, the next note in chords are compared, if they exist.
For example, a,
sorts lower than a,ce
.
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 in pitch, as if
inverting a broken chord. If notes
contains chords, they are broken into
successive notes. Then all notes are ordered by pitch. Finally shifting
occurs.
Instead of a moving window, note_arpeggiate()
grows its sequence from the
original set of timesteps by repeating the entire sequence n
times (n
must be positive). Each repeated sequence contributing to the arpeggio is
offset by step
semitones from the original. step
can be negative. It
defaults to 12, increasing all notes
by one octave.
x <- "bd'f#' a c'e'g' b ba c'g' gd'g'd''"
note_sort(x)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: <gd'g'd''> a <ba> b <bd'f#'> <c'e'g'> <c'g'>
note_sort(x, decreasing = TRUE)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: <c'g'> <c'e'g'> <bd'f#'> b <ba> a <gd'g'd''>
x <- "e_2 a_, c#f#a#"
note_slice(x, 2:3)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: a_, <d_g_b_>
note_slice(x, c(FALSE, TRUE, TRUE))
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: a_, <d_g_b_>
note_rotate(x, 1)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: a_, <d_g_b_> e_,
note_shift("c e g", 1)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: e g c'
note_shift("c e g", -4)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: g,, c, e,
note_arpeggiate("c e g ceg", 3)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: c e g <ceg> c' e' g' <c'e'g'> c'' e'' g'' <c''e''g''> c''' e''' g''' <c'''e'''g'''>
note_arpeggiate("c e g", 3, step = -12)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: c e g c, e, g, c,, e,, g,, c,,, e,,, g,,,
note_arpeggiate("g e c", 3, step = -12)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: g e c g, e, c, g,, e,, c,, g,,, e,,, c,,,
note_arpeggiate("c e_ g_ a", 3, step = 3)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: c e_ g_ a e_ g_ a c' g_ a c' e_' a c' e_' g_'
note_arpeggiate("c a g_ e_", 3, step = -3)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: c a g_ e_ a, g_ e_ c g_, e_ c a, e_, c a, g_,