Socket
Book a DemoInstallSign in
Socket

music-math

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

music-math

A utility library for calculating musical information e.g. a note from a frequency

0.1.1
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

music-math

travis npm js-standard-style

A utility library for calculating musical information e.g. a note from a frequency

math

Install

$ npm install --save music-math

Usage

var Frequency = require('music-math').Frequency;

var freqDetails = Frequency(440)

console.log(JSON.stringify(freqDetails))
//=> {"frequency":440,"noteNumber":57,"note":"A","octave":4,"offset":0}

API

Frequency(frequency)

frequency

  • Required
  • Type: number

The frequency to perform calculations on (in Hz).

Returns an object with the following properties (lazily calculated first time you request them):

frequency
  • Type: number

The frequency of the note (in Hz)

noteNumber
  • Type: number

The number of the [closest matching] note in the scale

note
  • Type: string

The [closest matching] note in the scale

octave
  • Type: number

The octave the frequency resides in

offset
  • Type: number

The measure of how off pitch the frequency is from the closest matching note (in cents)

Contributing

Help Wanted!

This utility was pulled out of a little fun side project I was working on - I am by no means versed in musical theory. I would be immensely grateful of any help especially in the form of:

  • corrections to my terminology
  • corrections to the math
  • additional test cases (especially failing ones that reveal flaws in my math!)

All pull requests / issues / feedback welcome :) Thanks!

Build

npm run build

Test

npm test

Watch

To watch for changes, build them and run the tests:

npm run watch

License

MIT © James Bunt

FAQs

Package last updated on 24 May 2015

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.