HzToSemitones: Convert Hz to semitones

Description Usage Arguments Examples

View source: R/utilities_math.R

Description

Converts from Hz to semitones above C-5 (~0.5109875 Hz). This may not seem very useful, but note that this gives us a nice logarithmic scale for generating natural pitch transitions with the added benefit of getting musical notation for free from notesDict (see examples).

Usage

1
HzToSemitones(h, ref = 0.5109875)

Arguments

h

vector or matrix of frequencies (Hz)

ref

frequency of the reference value (defaults to C-5, 0.51 Hz)

Examples

1
2
3
4
s = HzToSemitones(c(440, 293, 115))
# to convert to musical notation
notesDict$note[1 + round(s)]
# note the "1 +": semitones ABOVE C-5, i.e. notesDict[1, ] is C-5

soundgen documentation built on Oct. 4, 2018, 9:04 a.m.