Function for creating new chord definition tables.
chord_def(fret, id, optional = NA, tuning = "standard", ...)
integer vector defining fretted chord. See details.
character, the chord type. See details.
NA
when all notes required. Otherwise an integer
vector giving the indices offret
that are considered optional notes
for the chord.
character, string tuning. See tunings
for predefined
tunings. Custom tunings are specified with a similar value
string.
additional arguments passed to transpose()
.
a data frame
This function creates a tibble data frame containing information defining
various attributes of chords.
It is used to create the guitarChords
dataset, but can be used to create
other pre-defined chord collections.
The tibble has only one row, providing all information for the defined chord.
The user can decide which arguments to vectorize over when creating a chord
collection. See examples.
This function uses a vector of fret integers (NA
for muted string) to
define a chord, in conjunction with a string tuning
(defaults to standard
tuning, six-string guitar). fret
is from lowest to highest pitch strings,
e.g., strings six through one.
The id
is passed directly to the output. It represents the type of chord
and should conform to accepted tabr
notation. See id
column in
guitarChords
for examples.
Note that the semitones
column gives semitone intervals between chord
notes. These count from zero as the lowest pitch based on the tuning of the
instrument, e.g., zero is E2 with standard guitar tuning. To convert these
semitone intervals to standard semitone values assigned to pitches, use
e.g., pitch_semitones("e2")
(40) if that is the lowest pitch and add
that value to the instrument semitone interval values.
This is the explanation, but doing this is not necessary. You can use
chord_semitones()
to compute semitones directly on pitches in a
chord.
frets <- c(NA, 0, 2, 2, 1, 0)
chord_def(frets, "m")
#> # A tibble: 1 × 13
#> id lp_name root octave root_fret min_fret bass_string notes frets
#> <chr> <chr> <chr> <int> <dbl> <dbl> <int> <chr> <chr>
#> 1 m a,:m a 2 0 0 5 a,eac'e' xo221o
#> # ℹ 4 more variables: semitones <list>, optional <lgl>, fretboard <chr>,
#> # open <lgl>
chord_def(frets, "m", 6)
#> # A tibble: 1 × 13
#> id lp_name root octave root_fret min_fret bass_string notes frets
#> <chr> <chr> <chr> <int> <dbl> <dbl> <int> <chr> <chr>
#> 1 m a,:m a 2 0 0 5 a,eac'e' xo221o
#> # ℹ 4 more variables: semitones <list>, optional <chr>, fretboard <chr>,
#> # open <lgl>
purrr::map_dfr(c(0, 2, 3), ~chord_def(frets + .x, "m"))
#> # A tibble: 3 × 13
#> id lp_name root octave root_fret min_fret bass_string notes frets
#> <chr> <chr> <chr> <int> <dbl> <dbl> <int> <chr> <chr>
#> 1 m a,:m a 2 0 0 5 a,eac'e' xo221o
#> 2 m b,:m b 2 2 2 5 b,g_bd'g_' x24432
#> 3 m c:m c 3 3 3 5 cgc'e_'g' x35543
#> # ℹ 4 more variables: semitones <list>, optional <lgl>, fretboard <chr>,
#> # open <lgl>