This module provides functions to map scale degrees to chromatic numbers suitable for MIDI use. A few basic scales are provided as well (modes of the major scale, as well as the harmonic minor scale). You may add other scales you need to the scaleChromatics map at runtime.
Members
(static, constant) numChromatics
Number of degrees in western chromatic scale
(static, constant) origin
Determines location of middle C (default is middle C = 60)
(static, constant) scaleChromatics
Map of scale name -> chromatic degrees of scale
Example
const result = core.scaleChromatics.Ionian
// <= [0,2,4,5,7,9,11]
Methods
(static) addScale(name, degrees, relativeScale)
Add a named scale to the set of available scales
Parameters:
Name | Type | Default | Description |
---|---|---|---|
name |
string | name of scale |
|
degrees |
Array.<(string|number)> | list of ascending scale degrees
(see |
|
relativeScale |
string |
Ionian
|
scale to which degrees are relative |
(static) chromatic(degree, optionsopt) → {number}
What is the chromatic number for this scale degree?
Example
// midi note for middle C
const result = core.chromatic(1)
// <= 60
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
degree |
string | number | format is '[#|b]<int>', where <int> is a 1-based scale degree |
|||||||||||||||||
options |
Object |
<optional> |
defaults are {scale='Ionian', octave=origin.octave, shift=origin.shift} Properties
|
Returns:
the chromatic number
- Type
- number
(static) chromatics(degrees, optionsopt) → {Array.<number>}
What are the chromatic numbers for degrees in a given scale?
Example
// midi notes for a CM7 chord
const result = core.chromatics([1, 3, 5, 7])
// <= [60,64,67,71]
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
degrees |
Array.<(string|int)> | ||
options |
Object |
<optional> |
Returns:
the chromatic numbers
- Type
- Array.<number>
(static) setOrigin(octave)
Sets octave which will yield middle C = 60
Parameters:
Name | Type | Description |
---|---|---|
octave |
int | the octave for middle C |