Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danigb/musical-note
Musical notes in javascript
https://github.com/danigb/musical-note
Last synced: 13 days ago
JSON representation
Musical notes in javascript
- Host: GitHub
- URL: https://github.com/danigb/musical-note
- Owner: danigb
- License: mit
- Created: 2015-07-15T17:10:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-19T01:03:42.000Z (over 9 years ago)
- Last Synced: 2023-04-11T13:58:27.583Z (over 1 year ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# musical-note
[![Code Climate](https://codeclimate.com/github/danigb/musical-note/badges/gpa.svg)](https://codeclimate.com/github/danigb/musical-note)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)_(Western, well tempered)_ note in javascript.
```js
var Note = require('musical-note')
Note('F#4')
Note('C').transpose('M3')
```### Usage
Install with npm: `npm i --save musical-note` and require the library:
```js
var Note = require('musical-note')
```### API
### Note(string)
Create a note object from string. The note object has the following properties:
- name: the pitch class (in upper case) with alterations. For example: `C#`, `Dbb`
- oct: the octave (an integer, can be negative)
- midi: the midi number (integer)
- freq: the note frequency (usin 440hz as A4)### note.transpose(interval)
Returns the name of the note transposed by an interval
```js
Note('C4').transpose('M2') // => 'D4'
```### note.distance(note)
Returns an interval name of the distance from the note to the given one.
```js
Note('C4').distance('D4') // => 'M2'
```### note.enharmonics()
Returns an array of strings with the note enharmonics. For example:
```js
Note('C#4').enharmonics() // => ['Db4', 'B##3']
```See [enharmonics](https://github.com/danigb/enharmonics) for more info.