Learn R Programming

soundgen (version 2.7.4)

HzToSemitones: Convert semitones to Hz and back

Description

Converts between Hz and semitones above C-5 (~0.5109875 Hz) or another reference frequency. This may not seem very useful, but note that this gives us a nice logarithmic scale for generating natural pitch transitions. Accepts vectors and missing values.

Usage

HzToSemitones(x, ref = 0.5109875)

semitonesToHz(x, ref = 0.5109875)

Arguments

x

A vector or matrix of frequencies

ref

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

See Also

HzToOther

Examples

Run this code
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

# Any reference tone can be specified. For ex., for semitones above C0, use:
HzToSemitones(440, ref = 16.35)
# TIP: see notesDict for a table of Hz frequencies to musical notation

semitonesToHz(c(117, 105, 60))

Run the code above in your browser using DataLab