https://github.com/danigb/music.interval
Music intervals
https://github.com/danigb/music.interval
Last synced: 7 months ago
JSON representation
Music intervals
- Host: GitHub
- URL: https://github.com/danigb/music.interval
- Owner: danigb
- License: mit
- Created: 2015-10-22T11:20:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-28T15:32:34.000Z (over 10 years ago)
- Last Synced: 2024-12-27T11:34:52.162Z (over 1 year ago)
- Language: JavaScript
- Size: 93.8 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# music.interval
[](https://travis-ci.org/danigb/music.interval)
[](https://codeclimate.com/github/danigb/music.interval)
[](https://github.com/feross/standard)
[](https://www.npmjs.com/package/music.interval)
[](https://www.npmjs.com/package/music.interval)
[](https://www.npmjs.com/package/music.kit)
Simple and fast musical interval library:
```js
var interval = require('music-interval')
interval.simplify('9M') // => '2M'
interval.invert('3M') // => '6m'
```
This is part of [music.kit](https://www.npmjs.com/package/music.kit). It uses [music.interval.parser](https://github.com/danigb/music.interval.parser) to parse intervals so see this library to understand interval string notation.
## Install
Via npm: `npm i --save music-interval`. Use browserify or webpack to create a browser compatible distribution, or get the [whole thing](https://github.com/danigb/music.kit)
## Usage
#### Simplify an interval
A simple interval is any interval that spawns an octave or less. You can simplify any interval (simplify a simple interval return itself):
```js
interval.simplify('9M') // => '2M'
interval.simplify('2M') // => '2M'
```
#### Get inversion of an interval
You can [invert](https://en.wikipedia.org/wiki/Inversion_(music)#Intervals) an interval with the `invert` function. Notice that all inverted intervals are simples:
```js
interval.invert('2M') // => '7m'
interval.invert('1P') // => '8P'
```
#### More ...
Read the [generated documentation](https://github.com/danigb/music.interval/blob/master/API.md) or take a look to [music.kit](https://github.com/danigb/music.kit)
## License
MIT License