music-interval

0.3.0 • Public • Published

music-interval

Code Climate js-standard-style

Simple and fast musical interval library:

var interval = require('music-interval')
interval.simplify('9M') // => '2M'
interval.invert('3M') // => '6m'

Install

Use npm: npm i --save music-interval and require it:

var interval = require('music-interval')

For browser use browserify or webpack.

API

invert

Get the inversion of an interval. The inversion of an interval is always a simple interval

Source:
Example
invert('3M') // => '6m'

semitones

Get the semitones of a interval

Source:
Example
semitones('5P') // => 7
semitones('-5P') // => -7

simplify

Simplify an interval

Source:
Example
simplify('9M') // => '2M'
simplify('-9M') // => '-2M'

type

Get the type of an interval ('P' for perfetable and 'M' for majorable)

It does NOT return the quality of the interval (@see interval/quality)

Source:
Example
type('4P') // => 'P'
type('5A') // => 'P'
type('3m') // => 'M'
type('2d') // => 'M'

interval()

Get an inversal string from source or null if not a valid interval

Source:

generated with docme

License

MIT License

Package Sidebar

Install

npm i music-interval

Weekly Downloads

1

Version

0.3.0

License

MIT

Last publish

Collaborators

  • danigb