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.69.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

ParamTypeDescription
refFloatthe tuning reference
maxDecimalsInteger(Optional) the maximum number of decimals (all by default)
noteString | Pitchthe 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

ParamTypeDescription
noteNumber | Stringthe 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

ParamTypeDescription
tuningFloat(Optional) the reference A4 tuning (440Hz by default)
freqNumberthe 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

ParamType
freqFloat

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

ParamTypeDescription
freqFloat
useSharpsBoolean(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

ParamType
baseFloat | Integer | String
freqFloat | Integer | String

Example

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

Keywords

FAQs

Package last updated on 06 Aug 2017

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