New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonal-freq

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-freq

Conversion between frequencies and note names

  • 0.67.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
decreased by-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

tonal-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.

You can install via npm: npm i --save tonal-freq

API Reference

toEqualTemp(ref)function

Return a function that converts midi or notes names to frequency using equal temperament.

toFreq(note)Float

Get the frequency of a pitch using equal temperament scale and A4 equal to 440Hz

fromEqualTemp(ref)function

Create a function that returns a midi number from a frequency using an equal temperament and ref frequency as 'A4' frequency.

midiFromFreq(freq)Integer

Get note from frequency using a equal temeperament scale and 440Hz as freq reference

fromFreq(freq)String

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

cents(base, freq)Float

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

toEqualTemp(ref) ⇒ function

Return a function that converts midi or notes names to frequency using equal temperament.

Kind: global function
Returns: function - the frequency calculator. It accepts midi numbers, note names, pitches and returns a float.

ParamTypeDescription
refFloatthe tuning reference

Example

import { toEqualTemp } from 'tonal-freq'
const toFreq = toEqualTemp(444)
toFreq('A3') // => 222

toFreq(note) ⇒ Float

Get the frequency of a pitch using equal temperament scale and A4 equal to 440Hz

Kind: global function
Returns: Float - the frequency in herzs

ParamTypeDescription
noteNumber | Stringthe note name or midi number

Example

import { toFreq } from 'tonal-freq'
toFreq('A4') // => 440
// using tonal
tonal.toFreq('C4') // => 261.6255653005986

fromEqualTemp(ref) ⇒ function

Create a function that returns a midi number from a frequency using an equal temperament and ref frequency as 'A4' frequency.

Kind: global function
Returns: function - a function that converts from frequency to midi

ParamTypeDescription
refFloatthe frequency of A4

midiFromFreq(freq) ⇒ Integer

Get note from frequency using a equal temeperament scale and 440Hz as freq reference

Kind: global function
Returns: Integer - midi number

ParamType
freqFloat

fromFreq(freq) ⇒ String

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

Kind: global function
Returns: String - note name

ParamType
freqFloat

cents(base, freq) ⇒ Float

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

Kind: global function
Returns: Float - The difference in cents

ParamType
baseFloat | Integer | String
freqFloat | Integer | String

Example

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

Keywords

FAQs

Package last updated on 22 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc