Conversion between frequencies and note names
tonal-freq is a collection of functions to perform calculations related to frequencies.
This is part of tonal music theory library.
``js`
var freq = require('tonal-freq')
freq.toFreq('A4') // => 440
freq.note(440) // => 'A4'
freq.noteAndDetune(320) // => ['C4', 200]

* freq
* .eqTempFreq(ref, maxDecimals, note) ⇒ Number
* .toFreq(note) ⇒ Float
* .eqTempFreqToMidi(tuning, freq) ⇒ Number
* .toMidi(freq) ⇒ Number
* .note(freq, useSharps) ⇒ String
* .cents(base, freq) ⇒ Integer
⇒ NumberThis function can be partially applied if note parameter is not present.
Kind: static method of freq
Returns: Number - the frequency
| Param | Type | Description |
| --- | --- | --- |
| ref | Float | the tuning reference |
| maxDecimals | Integer | (Optional) the maximum number of decimals (all by default) |
| note | String \| Pitch | the note to get the frequency from |
Example
`js`
eqTempFreq(444, 4, 'C3')
const toFreq = eqTempFreq(444, 2)
toFreq('A3') // => 222
⇒ FloatThis is an alias for: eqTempFreq(440, 2,
Kind: static method of freq
Returns: Float - the frequency in herzs
| Param | Type | Description |
| --- | --- | --- |
| note | Number \| String | the note name or midi number |
Example
`js`
freq.toFreq('A4') // => 440
freq.toFreq('C4') // => 261.63
⇒ NumberKind: static method of freq
Returns: Number - the midi number
| Param | Type | Description |
| --- | --- | --- |
| tuning | Float | (Optional) the reference A4 tuning (440Hz by default) |
| freq | Number | the frequency |
⇒ NumberThis is an alisas for: eqTempFreqToMidi(440, 2,
Kind: static method of freq
Returns: Number - midi number
| Param | Type |
| --- | --- |
| freq | Float |
Example
`js`
freq.toMidi(361) // => 59.96
⇒ StringKind: static method of freq
Returns: String - note name
| Param | Type | Description |
| --- | --- | --- |
| freq | Float | |
| useSharps | Boolean | (Optional) set to true to use sharps instead of flats |
Example
`js`
freq.note(440) // => 'A4'
⇒ IntegerKind: static method of freq
Returns: Integer - The difference in cents
| Param | Type |
| --- | --- |
| base | Float \| Integer \| String |
| freq | Float \| Integer \| String |
Example
`js``
import { cents } from 'tonal-freq'
cents('C4', 261) // => -4