Scale

Scale

Class representing a set of pitch classes within an EDO system (e.g., 0-11 in 12EDO, 0-16 in 17EDO, etc.)

(This class should have been called "Set" but because Set is a reserved work in JavaScript (as in most languages), "Scale" was selected as a compromise).


Constructor

# new Scale(pitches, parent)

Creates a set of pitch classes within the context of the edo system.

Unlike the EDO Class, this class mostly contains methods which are more directed at manipulating a set of pitch classes (regardless of their octave) or for methods which necessitate the context of a scale (like sequences). At the center of this class stand 6 collections (see "Namespaces" below) of functions.

  • Scale.to is a set of functions used to change between equivalent representations of the set.
  • Scale.count is a set of functions used to count stuff.
  • Scale.get is a set of functions used to manipulate and track, and generate stuff.
  • Scale.is is a set of functions used for boolean truth statements.
  • Scale.export is a set of functions used to export files.
  • Scale.show is a set of functions used to visualize various things.

In addition to the namespaces, Scale also has 5 methods that can be chained together:

  • Scale.invert() returns the inversion of the original Scale object as a new Scale object.
  • Scale.mode(n) returns the nth mode of the original Scale object as a new Scale object.
  • Scale.normal() returns the normal order of the original Scale object as a new Scale object.
  • Scale.prime() returns the prime form of the original Scale object as a new Scale object.
  • Scale.complement() returns the complement of the scale in the current EDO.

Remark: "pitch-classes" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.

Parameters:
Name Type Description
pitches Array.<number>

The pitch classes of the set.

parent EDO

and EDO context

Source:
Examples
//Basic usage 1:
let edo = new EDO(12) //create a new EDO context with 12 divisions.
let scale = new Scale([0,2,4,5,7,9,11],edo) //pass the pitch-classes and edo context to the scale

//Basic usage 2 (preferred):
let edo = new EDO(12) //create a new EDO context with 12 divisions.
let scale = edo.scale([0,2,4,5,7,9,11]) //create an instance of Scale through the EDO.scale method rather than
//for scale [0, 2, 3, 5, 6, 8, 9, 11 ] //octatonic
scale.count.transpositions() //returns 3
scale.is.mode_of([0, 1, 3, 4, 6, 7, 9, 10]) //returns true
scale.to.cents() //returns [0, 200, 300, 500, 600, 800, 900, 1100]
scale.get.stacks(3,2) //returns [ [ 0, 5, 9 ], [ 0, 4, 9 ] ]
//chain functions
let scale = edo.scale([0,2,4,5,7,9,11])
scale.mode(2) //the 3rd mode (1st is 0)
     .normal() //in normal order
     .invert() //inverted
     .prime() //in prime form
     .get.pitches() //returns [0, 1, 3, 5, 6, 8, 10]

Namespaces

count
export
get
is
show
to

Methods

# complement() → {Scale}

Returns a Scale object with pitches corresponding to the complement of the original scale in the current EDO.

Source:
Returns:
Type
Scale

# invert() → {Scale}

Returns a Scale object with pitches corresponding to the inversion of the original scale.

Source:
Returns:
Type
Scale

# mode(n) → {Scale}

Returns a Scale object with pitches corresponding to the nth mode of the original scale

Parameters:
Name Type Default Description
n Number 0

Mode number to be returned (starting at 0)

Source:
Returns:
Type
Scale

# normal() → {Scale}

Returns a Scale object with pitches corresponding to the normal order of the original scale.

Source:
Returns:
Type
Scale

# prime() → {Scale}

Returns a Scale object with pitches corresponding to the prime form of the original scale.

Source:
Returns:
Type
Scale