SCALESAPI.JS
Purpose
This library / module is your javascript swiss knife to easily work around musical scales even if you are not a musician.
Clearly, it will allow you to "sound good" and more importantly "sound in key" when you want to randomly play sounds.
- use cases
- Find the scale you're in, from a set of chords or notes (Ideal for composers)
- Find all existing chords and notes in a scale you're interested in working with
- related libraries
Installation:
You may import the code into an existing node.js project or import it directly into your HTML code
# local install to your project
npm install --save-dev scalesapi
var sc = require('scalesapi')
<script type="text/javascript" src="scalesAPI.min.js"></script>
<script type="text/javascript" src="scalesAPI.js"></script>
The module is instanciated in the object sc, which you can use right away
getScales("info")
Constructors
No constructor, the library consists of methods only.
It consists of three main functions :
- getScales: information about chords and notes existing in a scale
- getChords: information about chords existing in a scale
- getNotes: information about notes existing in a scale
Methods
getScales(action, [value])
getScales("names")
Get the list of names from all scales available in the config
- getScales("info", [scaleName])
getScales("info")
getScales("info","Major")
Get scales meta-data information (object) from the config:
- chord sequence for 3 notes chords
- chord sequence for 4 notes chords
- interval sequence
If is not provided, return data for all scales
getScales("object")
Get scales content from the config, for all keys in all scales:
scaleName
\__ keyName
\__ Chords3: [list of chords with 3 notes]
\__ Chords4: [list of chords with 4 notes]
\__ Notes: [list of notes present in the scale]
- getScales("fromChords", chordsArray)
getScales("fromChords",[])
getScales("fromChords",["Amin","Cmaj","Dmin"])
The most popular method. It allows you to know which keys in various scales a set of chords belongs to.
Returns an object containing this info:
scaleName
\__ keyName
- getScales("fromNotes", notesArray)
getScales("fromNotes",[])
getScales("fromNotes",["A","C","Db"])
The most popular method. It allows you to know which keys in various scales a set of notes belongs to.
Returns an object containing this info:
scaleName
\__ keyName
getChords(scaleName, [key], [nbNotes])
getChords("*")
Get the full list of unique chords in all scales
getChords("byRoot")
Get the full list of unique chords in all scales, grouped by key
getChords("Major")
Get the full list of unique chords in a specific scale . The list of available scales can be obtained from getScales("names")
- getChords(scaleName, keyName)
getChords("Major","E")
Get the full list of unique chords in a specific scale for a specific key
- getChords(scaleName, keyName, nbNotes)
getChords("Major","E", 3)
getChords("Major","E", 4)
Get the full list of unique chords in a specific scale, for a specific key and a specific nb of notes in the chords
getNotes(scaleName, [key])
getNotes("*")
Get the full list of unique notes in all scales and all keys. This is the equivalent of the chromatic scale.
getNotes("Harmonic Minor")
Get the full list of unique notes in a specicif scale for all keys
- getNotes(scaleName, keyName)
getNotes("Harmonic Minor","Eb")
Get the full list of unique notes in a specicif scale for a specific key