Filter or slice chords to extract individual notes.

chord_root(notes)

chord_top(notes)

chord_slice(notes, index)

Arguments

notes

character, a noteworthy string.

index

integer, the order of a note in a chord by pitch (not scale degrees).

Value

a noteworthy string

Details

These functions extract notes from chords such as the root note, the highest pitch, specific position among the notes by pitch, or trim chords to simplify them. They operate based only on ordered pitches.

For chord_slice(), any entry that is empty after slicing is dropped. An error is thrown is index is completely out of bounds for all chords.

Examples

x <- "a_2 c#eg# e_gc egc,cc'"
chord_root(x)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: a_, d_ c c,
chord_top(x)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: a_, a_ g c'
identical(chord_slice(x, 1), chord_root(x))
#> [1] TRUE
chord_slice(x, 2)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: e e_ c
chord_slice(x, 4)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: g
chord_slice(x, 3:5)
#> <Noteworthy string>
#>   Format: space-delimited time
#>   Values: g# g <egc'>