scaleDegree.js

This module is a IIFE (Immediately Invoked Function Expression) and it returns a var with the name of scaleDegree. This document contains its public API.

This module uses the jazz method of describing a major scale: 1 2 3 4 5 6 7 8 and it uses # and b as modifiers. They must be a string (not numbers) so that sharps (#) or flats (b) can be used to modify
i.e. '1 b2 b3 4 5 b6 b7 8' represents a phrygian scale. These patterns can be transposed to any starting location with a MIDI number offset. The output of this library can be used with Tone.js to play notes and chords.

scaleDegree.js
Returns
object: scaleDegree object
Example
<script src="scaleDegree.js"></script>
...
var myChordProg = scaleDegree.makeII_V_I_Major("A4")
var myBassline = scaleDegree.makeII_V_I_Major_WalkBass("A4")
these can be used with Tone.js

makeII_V_I_Major

this function creates a II-V-I voicing in major

makeII_V_I_Major(key: string, optionalStartTime: string, optionalRhythm: string, optionalVoicing: string): object
Parameters
key (string)
optionalStartTime (string)
optionalRhythm (string)
optionalVoicing (string)
Returns
object: array used with Tone.js to play chord progression

makeII_V_I_Minor

this function creates a II-V-I voicing in minor

makeII_V_I_Minor(key: string, optionalStartTime: string, optionalRhythm: string, optionalVoicing: string): object
Parameters
key (string)
optionalStartTime (string)
optionalRhythm (string)
optionalVoicing (string)
Returns
object: array used with Tone.js to play chord progression

II_V_I_MAJOR_v1

this function creates a II-V-I voicing array in major

new II_V_I_MAJOR_v1(key: string): string
Parameters
key (string)
Returns
string: array of [name, root, voicing] for each of the II V and I chords

II_V_I_MAJOR_v2

this function creates a II-V-I voicing array in major

new II_V_I_MAJOR_v2(key: string): string
Parameters
key (string)
Returns
string: array of [name, root, voicing] for each of the II V and I chords

II_V_I_MAJOR_v3

this function creates a II-V-I voicing array in major

new II_V_I_MAJOR_v3(key: string): string
Parameters
key (string)
Returns
string: array of [name, root, voicing] for each of the II V and I chords

II_V_I_MINOR_v1

this function creates a II-V-I voicing array in minor

new II_V_I_MINOR_v1(key: string): string
Parameters
key (string)
Returns
string: array of [name, root, voicing] for each of the II V and I chords

II_V_I_MINOR_v2

this function creates a II-V-I voicing array in minor

new II_V_I_MINOR_v2(key: string): string
Parameters
key (string)
Returns
string: array of [name, root, voicing] for each of the II V and I chords

II_V_I_MINOR_v3

this function creates a II-V-I voicing array in minor

new II_V_I_MINOR_v3(key: string): string
Parameters
key (string)
Returns
string: array of [chordName, root, voicing] for each of the II V and I chords

makeII_V_I_Major_WalkBass

this function creates a II-V-I walking bassline in major

makeII_V_I_Major_WalkBass(key: string, optionalStartTime: string, optionalRhythm: string, optionalScaleDegrees: string): object
Parameters
key (string)
optionalStartTime (string)
optionalRhythm (string)
optionalScaleDegrees (string)
Returns
object: array used with Tone.js to play walking bass pattern

makeII_V_I_Minor_WalkBass

this function creates a II-V-I walking bassline in minor

makeII_V_I_Minor_WalkBass(key: string, optionalStartTime: string, optionalRhythm: string, optionalScaleDegrees: string): object
Parameters
key (string)
optionalStartTime (string)
optionalRhythm (string)
optionalScaleDegrees (string)
Returns
object: array used with Tone.js to play walking bass pattern

makeRhythmAndChordProg

this function makes an array of objects of a chord progression

makeRhythmAndChordProg(rhythmArray: string, chordArray: string): object
Parameters
rhythmArray (string)
chordArray (string)
Returns
object: array used with Tone.js to play chord progression.

makeFreqArray

this function makes a Frequency array from a scaleFormula and root

makeFreqArray(scaleDegreeFormula: string, root: string): number
Parameters
scaleDegreeFormula (string)
root (string)
Returns
number: array of frequencies

makeNoteArray

this function makes a noteName array from a scaleFormula and root

makeNoteArray(scaleDegreeFormula: string, root: string): object
Parameters
scaleDegreeFormula (string)
root (string)
Returns
object: array of noteNames
Example
var harm_minor = '1 2 b3 4 5 b6 7 8';
var my_root = "G4";
var g_minor = scaleDegree.makeNoteArray(harm_minor, my_root);
// g_minor = ["G4","A4","Bb4","C5","D5","Eb5","F#5","G5"]

makeChordArray

this function makes a noteName chord array from a scaleDegreeChordArray and root

makeChordArray(scaleDegreeChordArray: string, root: string): object
Parameters
scaleDegreeChordArray (string)
root (string)
Returns
object: array of noteName
Example
var my_triad = '1 b3 5';
var my_root = "C#4";
var my_chord = scaleDegree.makeChordArray(my_triad, my_root);
// my_chord = ["C#4","E4","G#4"]

makeChordFreqArray

this function makes a frequency chord array from a scaleDegreeChordArray and root

makeChordFreqArray(scaleDegreeChordArray: string, root: string): object
Parameters
scaleDegreeChordArray (string)
root (string)
Returns
object: array of frequencies

makeMelody

this function makes an array of objects creating a melody

makeMelody(scaleDegreeFormula: string, root: string, rhythmArray: string, optionalStartTime: string, optionalVelocity: string): object
Parameters
scaleDegreeFormula (string)
root (string)
rhythmArray (string)
optionalStartTime (string)
optionalVelocity (string)
Returns
object: array used with Tone.js as melody
Example
var my_scale_degrees = "1 5 6 5";
var my_root = "C4";
var my_durations = ["4n","8n","4n","8n"];
var my_melody = scaleDegree.makeMelody(my_scale_degrees, my_root, my_durations);
// my_melody = [{{note: {value: "C4"}}, {duration: {value: "4n}}, {velocity: {value: 0.7}}},
//               {{note: {value: "G4"}}, {duration: {value: "8n}}, {velocity: {value: 0.7}}},
//                {{note: {value: "A4"}}, {duration: {value: "4n}}, {velocity: {value: 0.7}}},
//                 {{note: {value: "G4"}}, {duration: {value: "8n}}, {velocity: {value: 0.7}}}]

TransposeSequence

this function transposes an arrayOfNotes by a specified number of half steps

new TransposeSequence(arrayOfNotes: string, transposeHalfSteps: number): string
Parameters
arrayOfNotes (string)
transposeHalfSteps (number)
Returns
string: string array of transposed notes NOTE: doesn't deal with correct name but only the correct sounding pitch

getRoot

this function returns the letter name of any scale degree for a given key

getRoot(keyRoot: string, scaleDegree: string): string
Parameters
keyRoot (string)
scaleDegree (string)
Returns
string: noteName of scale degree