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
- Node module import
# local install to your project npm install --save-dev scalesapi
// import module into your js codevar sc =
- plain JS import
<!-- minified version, not human friendly, 56kb--><!-- uncompressed version, human friendly, 422kb -->
The module is instanciated in the object sc, which you can use right away
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")
//returns a list like ["Major", "Natural Minor", ...]
Get the list of names from all scales available in the config
- getScales("info", [scaleName])
//returns data for all scales //returns data for the Major scale only
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")
//returns 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)
//returns all keys in all scales //returns keys in two scales
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)
//returns all keys in all scales //returns keys in two scales
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("*")
//returns a list of chords
Get the full list of unique chords in all scales
- getChords("byRoot")
//returns a list of chords
Get the full list of unique chords in all scales, grouped by key
- getChords(scaleName)
//returns a list of all chords present in the Major scale, all keys included
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)
//returns a list of all chords present in the key of E in the Major scale
Get the full list of unique chords in a specific scale for a specific key
- getChords(scaleName, keyName, nbNotes)
//returns a list of all 3 notes chords present in the key of E in the Major scale //returns a list of all 4 notes chords present in the key of E in the Major scale
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("*")
//returns a list of notes
Get the full list of unique notes in all scales and all keys. This is the equivalent of the chromatic scale.
- getNotes(scaleName)
//returns a list of notes in the harmonic minor scale
Get the full list of unique notes in a specicif scale for all keys
- getNotes(scaleName, keyName)
//returns a list of notes in the harmonic minor scale, key of Eb
Get the full list of unique notes in a specicif scale for a specific key