*** deprecated: use tonal ***
This library is not longer maintained.
Extends note-parser to add note pitch manipulation.
As an extension of note-parser, you can parse notes:
var Note = require('note-pitch');
Note.parse('a4'); // => { pc: 'a', acc: '', oct: 4, midi: 69, freq: 440 }
But also you can transpose them:
Note.transpose('e4', 'M2'); // => 'f#4'
Note.transpose('c2', ["P1","M2","M3"]); // => ['c2', 'd2', 'e2']
Or find distances (in intervals):
Note.distance('c2', 'd2'); // => 'M2'
Note.distance('c', ['c', 'd', 'eb', 'f', 'g']); // => ['P1', 'M2', 'm3', 'P4', 'P5']
## Installation
Install the module: npm i --save note-pitch
and require it:
var Note = require('note-pitch');
If you want to use it inside a browser you will need a node module compatible packager (like browserify or webpack).
This is part of a higher level library that performs transpositions (and much more) ready to browser: ScoreJs
### Note.parse(note)
Returns the note as parsed object. See note-parser for more information.
Returns the distance in semitones between noteA and noteB (can be positive or negative number)
Transpose the given note by a interval:
Note.transpose('g5', 'm3'); // => "bb5";
If you skip the note, you get a transposer, a function that transpose notes by a certain interval:
var transposer = Note.transpose('M2');
transposer('c2'); // => "d2"
transposer('d2'); // => "e2"
transposer('e2'); // => "f#2"
Also, you can specify an array of intervals, ideal for building chords or scales:
Note.transpose('c2', ['P1', 'M2', 'm3']); // => ["c2", "d2", "eb3"]
Note.transpose('a2', ['P1', 'M3', 'P5']); // => ["a2", "c#3", "e3"]
### Note.distance(root, notes)
Returns the distance between a root note and a list of notes:
Note.distance('c2', 'd2'); // => "M2"
Note.distance('c2', ['c2', 'd2', 'e2']); // => ['P1', 'M2', 'M3']
If you skip the notes, you get a distancer, a function that returns the distance from the root to another note:
var distance = Note.distance('c2');
distance('c2'); // => 'P1'
distance('d2'); // => 'M2'
MIT License