Giter Site home page Giter Site logo

music-math's Introduction

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

music-math's People

Contributors

unkillbob avatar

Watchers

James Cloos avatar David Kurek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.