scale-deg | R Documentation |
These functions assist with mapping between scale degrees, notes and chords.
scale_degree(
notes,
key = "c",
scale = "diatonic",
use_root = TRUE,
strict_accidentals = TRUE,
naturalize = FALSE,
roman = FALSE
)
scale_note(deg, key = "c", scale = "diatonic", collapse = FALSE, ...)
note_in_scale(
notes,
key = "c",
scale = "diatonic",
use_root = TRUE,
strict_accidentals = TRUE
)
chord_degree(
notes,
key = "c",
scale = "diatonic",
strict_accidentals = TRUE,
naturalize = FALSE,
roman = FALSE
)
is_in_scale(notes, key = "c", scale = "diatonic", strict_accidentals = TRUE)
notes |
character, a string of notes. |
key |
character, key signature (or root note) for scale, depending on
the type of |
scale |
character, the suffix of a supported |
use_root |
logical, use lowest pitch in chord. Otherwise yield an
|
strict_accidentals |
logical, whether representation must match key and scale. See details. |
naturalize |
logical, whether to naturalize any sharps or flats before obtaiuning the scale degree. |
roman |
logical, return integer scale degrees as Roman numerals. |
deg |
integer, roman class, or character roman, the scale degree. |
collapse |
logical, collapse result into a single string ready for phrase construction. |
... |
additional arguments passed to the scale function, e.g.,
|
Obtain the scale degree of a note in a supported scale with scale_degree()
.
This function works on any noteworthy string. It ignores octave numbering.
Rests and any note not explicitly in the scale return NA
. If deg
is
greater than the number of degrees in the scale, it is recycled, e.g., in C
major 8 starts over as C.
By default, flats and sharps checked strictly against the scale. Setting
strict_accidentals = FALSE
will convert any flats or sharps present,
if necessary based on the combination of key
signature and
scale
. The chromatic scale is a special case where strict accidental
is always ignored.
Not any arbitrary combination of valid key
and valid scale
is valid. For
example, key = "am"
and scale = "harmonic"
is valid, but not with
key = "a"
.
note_in_scale()
is a wrapper around scale_degree()
. To check if full
chords are diatonic to the scale, see is_diatonic()
.
The inverse of scale_degree()
is scale_note()
, for obtaining the note
associated with a scale degree. This could be done simply by calling a
scale_*
function and indexing its output directly, but this wrapper is
provided to complement scale_degree()
.
Additionally, it accepts the common Roman numeral input for the degree.
This can be with the roman
class or as a character string.
Degrees return NA
if outside the scale degree range.
integer, or roman class if roman = TRUE
for scale_degree()
;
character for scale_note()
.
scale-helpers()
, is_diatonic()
scale_degree("r c, e3 g~ g s g# ceg")
note_in_scale("r c, e3 g~ g s g# ceg")
scale_degree("c e g", roman = TRUE)
scale_degree("c c# d_ e", key = "d")
scale_degree("c c# d_ e", key = "d", strict_accidentals = FALSE)
scale_degree("c, e_3 g' f#ac#", use_root = FALSE)
scale_degree("c, e_3 g' f#ac#", naturalize = TRUE) # lowest chord pitch: c#
scale_degree("c# d_ e_' e4 f f# g", key = "c#", scale = "chromatic")
scale_note(1:3, key = "am")
scale_note(c(1, 3, 8), "d", collapse = TRUE)
all(sapply(list(4, "IV", as.roman(4)), scale_note) == "f")
x <- "d dfa df#a f#ac#"
chord_degree(x, "d")
is_in_scale(x, "d")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.