music-math
v0.1.1
Published
A utility library for calculating musical information e.g. a note from a frequency
Downloads
1
Readme
music-math
A utility library for calculating musical information e.g. a note from a frequency
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