Helper functions for chord mapping.

gc_info(
  name,
  root_octave = NULL,
  root_fret = NULL,
  min_fret = NULL,
  bass_string = NULL,
  open = NULL,
  key = "c",
  ignore_octave = TRUE
)

gc_fretboard(
  name,
  root_octave = NULL,
  root_fret = NULL,
  min_fret = NULL,
  bass_string = NULL,
  open = NULL,
  key = "c",
  ignore_octave = TRUE
)

gc_notes_to_fb(
  notes,
  root_octave = NULL,
  root_fret = NULL,
  min_fret = NULL,
  bass_string = NULL,
  open = NULL
)

gc_notes(
  name,
  root_octave = NULL,
  root_fret = NULL,
  min_fret = NULL,
  bass_string = NULL,
  open = NULL,
  key = "c",
  ignore_octave = TRUE
)

gc_is_known(notes)

gc_name_split(name)

gc_name_root(name)

gc_name_mod(name)

Arguments

name

character, chord name in tabr format, e.g., "bM b_m b_m7#5", etc.

root_octave

integer, optional filter for chords whose root note is in a set of octave numbers. May be a vector.

root_fret

integer, optional filter for chords whose root note matches a specific fret. May be a vector.

min_fret

integer, optional filter for chords whose notes are all at or above a specific fret. May be a vector.

bass_string

integer, optional filter for chords whose lowest pitch string matches a specific string, 6, 5, or 4. May be a vector.

open

logical, optional filter for open and movable chords. NULL retains both types.

key

character, key signature, used to enforce type of accidentals.

ignore_octave

logical, if TRUE, functions like gc_info() and gc_fretboard() return more results.

notes

character, a noteworthy string.

Value

various, see details regarding each function.

Details

These functions assist with mapping between different information that define chords.

For gc_is_known(), a check is done against chords in the guitarChords dataset. A simple noteworthy string is permitted, but any single-note entry will automatically yield a FALSE result.

gc_info() returns a tibble data frame containing complete information for the subset of predefined guitar chords specified by name and key. Any accidentals present in the chord root of name (but not in the chord modifier, e.g., m7_5 or m7#5) are converted according to key if necessary. gc_notes() and gc_fretboard() are wrappers around gc_info(), which return noteworthy strings of chord notes and a named vector of LilyPond fretboard diagram data, respectively. Note that although the input to these functions can contain multiple chord names, whether as a vector or as a single space-delimited string, the result is not intended to be of equal length. These functions filter guitarChords. The result is the set of all chords matched by the supplied input filters.

gc_name_split() splits a vector or space-delimited set of chord names into a tibble data frame containing separate chord root and chord modifier columns. gc_name_root() and gc_name_mod() are wrappers around this.

Examples

gc_is_known("a b_,fb_d'f'")
#> [1] FALSE  TRUE

gc_name_root("a aM b_,m7#5")
#> [1] "a"   "a"   "b_,"
gc_name_mod("a aM b_,m7#5")
#> [1] "M"    "M"    "m7#5"

gc_info("a") # a major chord, not a single note
#> # A tibble: 6 × 12
#>   id    lp_name root  octave root_fret min_fret bass_string notes        frets  
#>   <fct> <chr>   <chr>  <dbl>     <dbl>    <dbl>       <int> <chr>        <chr>  
#> 1 M     a,:5    a          2         0        0           5 a,ead_'e'    xo222o 
#> 2 M     a,:5    a          2         5        5           6 a,ead_'e'a'  577655 
#> 3 M     a,:5    a          2         5        2           6 a,d_ead_'a'  542225 
#> 4 M     a:5     a          3         7        7           4 ae'a'd_''    xx79(1…
#> 5 M     a:5     a          3        12       12           5 ae'a'd_''e'' x(12)(…
#> 6 M     a:5     a          3        12        9           5 ad_'e'a'd_'' x(12)(…
#> # ℹ 3 more variables: semitones <list>, fretboard <chr>, open <lgl>
gc_info("ceg a#m7_5") # only second entry is a guitar chord
#> # A tibble: 6 × 12
#>   id    lp_name  root  octave root_fret min_fret bass_string notes        frets 
#>   <fct> <chr>    <chr>  <dbl>     <dbl>    <dbl>       <int> <chr>        <chr> 
#> 1 m7_5  b_,:m7_5 b_         2         1        0           5 b_,a_d_'e'   x1x12o
#> 2 m7_5  b_,:m7_5 b_         2         1        1           5 b_,ea_d_'    x1212x
#> 3 m7_5  b_,:m7_5 b_         2         6        5           6 b_,a_d_'e'   6x665x
#> 4 m7_5  b_:m7_5  b_         3         8        4           4 b_d_'e'a_'   xx8654
#> 5 m7_5  b_:m7_5  b_         3         8        8           4 b_e'a_'d_''  xx8999
#> 6 m7_5  b_:m7_5  b_         3        13       12           5 b_a_'d_''e'' x(13)…
#> # ℹ 3 more variables: semitones <list>, fretboard <chr>, open <lgl>
gc_info("ceg a#m7_5", key = "f")
#> # A tibble: 6 × 12
#>   id    lp_name  root  octave root_fret min_fret bass_string notes        frets 
#>   <fct> <chr>    <chr>  <dbl>     <dbl>    <dbl>       <int> <chr>        <chr> 
#> 1 m7_5  b_,:m7_5 b_         2         1        0           5 b_,a_d_'e'   x1x12o
#> 2 m7_5  b_,:m7_5 b_         2         1        1           5 b_,ea_d_'    x1212x
#> 3 m7_5  b_,:m7_5 b_         2         6        5           6 b_,a_d_'e'   6x665x
#> 4 m7_5  b_:m7_5  b_         3         8        4           4 b_d_'e'a_'   xx8654
#> 5 m7_5  b_:m7_5  b_         3         8        8           4 b_e'a_'d_''  xx8999
#> 6 m7_5  b_:m7_5  b_         3        13       12           5 b_a_'d_''e'' x(13)…
#> # ℹ 3 more variables: semitones <list>, fretboard <chr>, open <lgl>

gc_info("a,m c d f,")
#> # A tibble: 23 × 12
#>    id    lp_name root  octave root_fret min_fret bass_string notes       frets  
#>    <fct> <chr>   <chr>  <dbl>     <dbl>    <dbl>       <int> <chr>       <chr>  
#>  1 m     a,:m    a          2         0        0           5 a,eac'e'    xo221o 
#>  2 m     a,:m    a          2         5        5           6 a,eac'e'a'  577555 
#>  3 m     a,:m    a          2         5        2           6 a,cea       5322xx 
#>  4 m     a:m     a          3         7        7           4 ae'a'c''    xx79(1…
#>  5 m     a:m     a          3        12       12           5 ae'a'c''e'' x(12)(…
#>  6 m     a:m     a          3        12        9           5 ac'e'a'     x(12)(…
#>  7 M     c:5     c          3         3        3           5 cgc'e'g'    x35553 
#>  8 M     c:5     c          3         3        0           5 cegc'e'     x32o1o 
#>  9 M     c:5     c          3         8        8           6 cgc'e'g'c'' 8(10)(…
#> 10 M     c:5     c          3         8        5           6 cegc'e'c''  875558 
#> # ℹ 13 more rows
#> # ℹ 3 more variables: semitones <list>, fretboard <chr>, open <lgl>
gc_fretboard("a,m c d f,", root_fret = 0:3)
#>           a,:m            c:5            c:5            d:5           f,:5 
#> "x;o;2;2;1;o;" "x;3;5;5;5;3;" "x;3;2;o;1;o;" "x;x;o;2;3;2;" "1;3;3;2;1;1;" 
#>            f:5 
#> "x;x;3;5;6;5;" 
gc_notes_to_fb("a,eac'e' cgc'e'g'")
#>           a,:m            c:5 
#> "x;o;2;2;1;o;" "x;3;5;5;5;3;" 

x <- gc_notes("a, b,", root_fret = 0:2)
summary(x)
#> <Noteworthy string>
#>   Timesteps: 2 (0 notes, 2 chords)
#>   Octaves: tick
#>   Accidentals: flat
#>   Format: space-delimited time
#>   Values: <a,ead_'e'> <b,g_be_'g_'>