Helper functions for key signature information.

keys(type = c("all", "sharp", "flat"))

key_is_natural(key)

key_is_sharp(key)

key_is_flat(key)

key_n_sharps(key)

key_n_flats(key)

key_is_major(key)

key_is_minor(key)

Arguments

type

character, defaults to "all".

key

character, key signature.

Value

character vector.

Details

The keys() function returns a vector of valid key signature IDs. These IDs are how key signatures are specified throughout tabr, including in the other helper functions here via key. Like the other functions here, key_is_sharp() and key_is_flat() are for key signatures, not single pitches whose sharp or flat status is always self-evident from their notation. Major and minor keys are also self-evident from their notation, but key_is_major() and key_is_minor() can still be useful when programming.

Examples

keys()
#>  [1] "c"   "g"   "d"   "a"   "e"   "b"   "f#"  "c#"  "f"   "b_"  "e_"  "a_" 
#> [13] "d_"  "g_"  "c_"  "am"  "em"  "bm"  "f#m" "c#m" "g#m" "d#m" "a#m" "dm" 
#> [25] "gm"  "cm"  "fm"  "b_m" "e_m" "a_m"
key_is_natural(c("c", "am", "c#"))
#> [1]  TRUE  TRUE FALSE
x <- c("a", "e_")
key_is_sharp(x)
#> [1]  TRUE FALSE
key_is_flat(x)
#> [1] FALSE  TRUE
key_n_sharps(x)
#> [1] 3 0
key_n_flats(x)
#> [1] 0 3