Helper functions for working with musical modes.

modes(mode = c("all", "major", "minor"))

is_mode(notes, ignore_octave = FALSE)

mode_rotate(notes, n = 0, ignore_octave = FALSE)

mode_modern(
  mode = "ionian",
  key = "c",
  collapse = FALSE,
  ignore_octave = FALSE
)

mode_ionian(key = "c", collapse = FALSE, ignore_octave = FALSE)

mode_dorian(key = "c", collapse = FALSE, ignore_octave = FALSE)

mode_phrygian(key = "c", collapse = FALSE, ignore_octave = FALSE)

mode_lydian(key = "c", collapse = FALSE, ignore_octave = FALSE)

mode_mixolydian(key = "c", collapse = FALSE, ignore_octave = FALSE)

mode_aeolian(key = "c", collapse = FALSE, ignore_octave = FALSE)

mode_locrian(key = "c", collapse = FALSE, ignore_octave = FALSE)

Arguments

mode

character, which mode.

notes

character, for mode, may be a noteworthy string of seven notes, space- or vector-delimited.

ignore_octave

logical, strip octave numbering from modes not rooted on C.

n

integer, degree of rotation.

key

character, key signature.

collapse

logical, collapse result into a single string ready for phrase construction.

Value

character

Details

For valid key signatures, see keys().

Modern modes based on major scales are available by key signature using the mode_* functions. The seven modes can be listed with modes. Noteworthy strings of proper length can be checked to match against a mode with is_mode(). Modes can be rotated with mode_rotate(), a wrapper around note_rotate().

Examples

modes()
#> [1] "ionian"     "dorian"     "phrygian"   "lydian"     "mixolydian"
#> [6] "aeolian"    "locrian"   
mode_dorian("c")
#> <Noteworthy string>
#>   Format: vectorized time
#>   Values: c d e_ f g a b_
mode_modern("dorian", "c")
#> <Noteworthy string>
#>   Format: vectorized time
#>   Values: c d e_ f g a b_
mode_modern("dorian", "c", ignore_octave = TRUE)
#> <Noteworthy string>
#>   Format: vectorized time
#>   Values: c d e_ f g a b_

identical(mode_rotate(mode_ionian("c"), 1), mode_dorian("d"))
#> [1] TRUE
identical(
  mode_rotate(mode_ionian("c", ignore_octave = TRUE), 1),
  mode_dorian("d", ignore_octave = TRUE)
)
#> [1] TRUE

x <- sapply(modes(), mode_modern, ignore_octave = TRUE)
setNames(data.frame(t(x)), as.roman(1:7))
#>            I II III IV  V VI VII
#> ionian     c  d   e  f  g  a   b
#> dorian     c  d  e_  f  g  a  b_
#> phrygian   c d_  e_  f  g a_  b_
#> lydian     c  d   e g_  g  a   b
#> mixolydian c  d   e  f  g  a  b_
#> aeolian    c  d  e_  f  g a_  b_
#> locrian    c d_  e_  f g_ a_  b_