Classes | Math | Tuning

Scale : Object

represents a musical scale
Subclasses: ScaleAD


Scale supports arbitrary octave divisions and ratios, and (in conjunction with Tuning) can generate pitch information in various ways, including as input to Patterns.


*major, *minor, *dorian, *chromatic, *todi, *hijaz, *partch_o1, etc.

Creates a scale from the library stored in the instance variable "all". Each scale comes with an appropriate default Tuning, but alternate tunings can be specified at creation time:

If the tuning size does not match the scale's -pitchesPerOctave, a warning will be thrown, and the scale will use its default tuning.

For a complete list of available scales, execute

Class Methods


The scale repository, to which new scales can be added.

Access from the scale repository.

Scale.choose(size: 7, pitchesPerOctave: 12)

Creates a random scale from the library, constrained by size and pitchsPerOctave if desired. 'ionian', pitchesPerOctave, tuning, name: "Unknown Scale")

Creates a Scale from scratch. degrees should be an array of Integers or scale name. If pitchesPerOctave is nil, will guess the most appropriate number based on degrees. tuning can be an instance of Tuning or a symbol; if nil, will be equal temperament of pitchesPerOctave. Specify descDegrees if the Scale should play differently when descending than when ascending; otherwise it should be nil.

Scale.chromatic(tuning: 'et12')

Returns a chromatic scale for a specific tuning.

Inherited class methods

Undocumented class methods


Scale.doesNotUnderstand(selector, args)


Scale.newFromKey(key, tuning)

Instance Methods


.tuning = inTuning

Sets or gets the tuning of the Scale.



can be either an instance of Tuning or a symbol matching a library tuning.


Returns a tuned array of semitone values. -as(Array) is equivalent; -as(List) returns it as a list, etc.


Returns a tuned array of cent values.


Returns a tuned array of ratios.


Converting. For example as(Array), as(List) and as(LocalBuf) which is useful for server-side work.


Returns the length of the scale.


Returns the size of the pitch class set from which the tuning is drawn.


Usually 12, but may be different if the current tuning has a stretched or compressed octave. Needed for degreeToKey.

but note:



These access the array generated by semitones.

.degreeToFreq(degree, rootFreq, octave)

Returns a frequency based on current tuning and rootFreq argument.

.degreeToRatio(degree, octave: 0)

Returns a ratio based on current tuning.

Inherited instance methods

Undocumented instance methods







.name = value


.performDegreeToKey(scaleDegree, stepsPerOctave, accidental: 0)

.performKeyToDegree(degree, stepsPerOctave: 12)


.performNearestInScale(degree, stepsPerOctave: 12)