Convert between pitches, chords, semitones and frequencies.
pitch_freq(notes, a4 = 440) pitch_semitones(notes) chord_freq(notes, a4 = 440) chord_semitones(notes) freq_pitch( freq, octaves = c("tick", "integer"), accidentals = c("flat", "sharp"), collapse = FALSE, a4 = 440 ) freq_semitones(freq, a4 = 440) semitone_pitch( semitones, octaves = c("tick", "integer"), accidentals = c("flat", "sharp"), collapse = FALSE ) semitone_freq(semitones, a4 = 440)
notes | character, noteworthy string, space-delimited or vector of individual entries. See details. |
---|---|
a4 | the fixed frequency of the A above middle C, typically 440 Hz. |
freq | numeric vector, frequencies in Hz. |
octaves |
|
accidentals |
|
collapse | logical, collapse result into a single string.
|
semitones | integer values of pitches. |
integer, numeric or noteworthy vector
Frequencies are in Hertz. Values are based on the 12-tone equal-tempered
scale. When converting an arbitrary frequency to pitch, it is rounded to the
nearest pitch.
pitch_freq
and pitch_semitones
strictly accept single notes in
noteworthy strings and return numeric vectors.
chord_freq
and chord_semitones
accept any noteworthy string
and always return a list. These are provided so that all functions are
type-safe. See examples.
x <- "a e4 a4 e5 a5" y <- pitch_freq(x) y#> [1] 220.0000 329.6276 440.0000 659.2551 880.0000freq_semitones(y)#> [1] 57 64 69 76 81freq_pitch(y)#> <Noteworthy string> #> Format: vectorized time #> Values: a e' a' e'' a''#> [1] TRUEs <- pitch_semitones(x) s#> [1] 57 64 69 76 81semitone_pitch(s)#> <Noteworthy string> #> Format: vectorized time #> Values: a e' a' e'' a''x <- "a, a,c#e" chord_semitones(x)#> $`a,` #> [1] 45 #> #> $`a,c#e` #> [1] 45 49 52 #>chord_freq(x)#> $`a,` #> [1] 110 #> #> $`a,c#e` #> [1] 110.0000 138.5913 164.8138 #>