core

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.

Source:

Members

(static, constant) numChromatics

Source:

Number of degrees in western chromatic scale

(static, constant) origin

Source:

Determines location of middle C (default is middle C = 60)

(static, constant) scaleChromatics

Source:

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)

Source:

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 module:core.chromatic)

relativeScale string Ionian

scale to which degrees are relative

(static) chromatic(degree, optionsopt) → {number}

Source:

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
Name Type Attributes Description
scale string <optional>

name of scale to use

octave number <optional>

default octave for notes with no designation

shift number <optional>

an integer used to shift the value up or down on the number line

Returns:

the chromatic number

Type
number

(static) chromatics(degrees, optionsopt) → {Array.<number>}

Source:

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)>

see module:core.chromatic

options Object <optional>

see module:core.chromatic

Returns:

the chromatic numbers

Type
Array.<number>

(static) setOrigin(octave)

Source:

Sets octave which will yield middle C = 60

Parameters:
Name Type Description
octave int

the octave for middle C