npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tonal-freq

v0.69.9

Published

Conversion between frequencies and note names

Readme

freq

npm version tonal

tonal-freq is a collection of functions to perform calculations related to frequencies.

This is part of tonal music theory library.

Usage

var freq = require('tonal-freq')
freq.toFreq('A4') // => 440
freq.note(440) // => 'A4'
freq.noteAndDetune(320) // => ['C4', 200]

Install

npm install tonal-freq

API Documentation

freq.eqTempFreq(ref, maxDecimals, note)Number

Return the equal tempered frequency of a note.

This 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

eqTempFreq(444, 4, 'C3')
const toFreq = eqTempFreq(444, 2)
toFreq('A3') // => 222

freq.toFreq(note)Float

Get the frequency of note with 2 decimals precission using A4 440Hz tuning

This is an alias for: eqTempFreq(440, 2, <note>)

Kind: static method of freq
Returns: Float - the frequency in herzs

| Param | Type | Description | | --- | --- | --- | | note | Number | String | the note name or midi number |

Example

freq.toFreq('A4') // => 440
freq.toFreq('C4') // => 261.63

freq.eqTempFreqToMidi(tuning, freq)Number

Get the midi note from a frequency in equal temperament scale. You can specify the number of decimals of the midi number.

Kind: 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 |

freq.toMidi(freq)Number

Get midi number from frequency with two decimals of precission.

This is an alisas for: eqTempFreqToMidi(440, 2, <freq>)

Kind: static method of freq
Returns: Number - midi number

| Param | Type | | --- | --- | | freq | Float |

Example

freq.toMidi(361) // => 59.96

freq.note(freq, useSharps)String

Get note name from frequency using an equal temperament scale with 440Hz as reference

Kind: 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

freq.note(440) // => 'A4'

freq.cents(base, freq)Integer

Get difference in cents between two frequencies. The frequencies can be expressed with hertzs or midi numbers or note names

Kind: static method of freq
Returns: Integer - The difference in cents

| Param | Type | | --- | --- | | base | Float | Integer | String | | freq | Float | Integer | String |

Example

import { cents } from 'tonal-freq'
cents('C4', 261) // => -4