DEPRECATED: All code moved to tonal: https://github.com/danigb/tonal/tree/master/packages/chord
Music chords made easy:
var chord = require('tonal.chord')
chord('CMaj7') // => ['C', 'E', 'G', 'B']
var dom7 = chord.build('C E G Bb')
dom7('A4') // => ['A4', 'C#5', 'E5', 'G5']
tonal.chord
is a compact library to create and manipulate chords, and a chord dictionary
This is part of tonal
Via npm: npm i --save tonal.chord
or add the distribution file to your html page (will set chord
global variable with the library)
A chord is an array of notes ordered by pitch starting with a tonic. Sometimes it can be expressed with intervals. With tonal.chord
you can:
chord
: create chords by name (and optionally a tonic)build
: create chords from a list of notestype
: get the chord type (major, minor, diminished, augmented)
You can get a chord by its tonic and name:
chord('Bb7') // => ['Bb', 'D', 'F', 'Ab']
Optionally, you can set the tonic as second parameter:
chord('7', 'Bb') // => ['Bb', 'D', 'F', 'Ab']
Or pass false
to get the intervals:
chord('7', false) // => ['1P', '3M', '5M', '7m']
Finally, you can partially apply the function by specifying only the chord type:
var V7 = chord('7')
V7('Bb') // => ['Bb', 'D', 'F', 'Ab']
You don't need the dictionary to create a chord. You can build a chord with a list of intervals:
chord.build('1 3 5 7b 9', 'F2') // => ['F2', 'A2', 'C3', 'Eb3', 'G3']
You can partially apply the function:
var dom79 = chord.build('1 3 5 7b 9')
dom79('F2') // => ['F2', 'A2', 'C3', 'Eb3', 'G3']
Its important to note that all chord notes are ordered by pitch:
chord.build('1 3 5 7 2', 'C') // => ['C', 'D', 'E', 'G', 'B']
If you don't need the chord dictionary you can require only the build
function to save size:
var chord = require('tonal.chord/build')
You can build from notes the same way (again, ordered notes):
var m7b5 = chord.build('C Eb Gb Bb')
m7b5('D4') // => ['D4', 'F4', 'Ab4', 'C5']
var maj7drop2 = chord.build('C2 E2 G1 B2')
maj7drop2('C4') // => [ 'G3', 'C4', 'E4', 'B4' ]
Read the generated documentation or get the whole stuff
To run the example npm install -g beefy
then beefy example/chords.js
and navigate to http://localhost:9966/
MIT License