Scale:
Filter:
Classes | Math | Tuning

Scale : Object

represents a musical scale
Source: Scale.sc
Subclasses: ScaleAD

Description

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

Creation

*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

Scale.all

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

Scale.at(key)

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.

Scale.new(degrees: '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.chooseFromSelected(selectFunc)

Scale.directory

Scale.doesNotUnderstand(selector, args)

Scale.names

Scale.newFromKey(key, tuning)

Instance Methods

.tuning

.tuning = inTuning

Sets or gets the tuning of the Scale.

Arguments:

inTuning

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

.semitones

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

.cents

Returns a tuned array of cent values.

.ratios

Returns a tuned array of ratios.

.as(class)

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

.size

Returns the length of the scale.

.pitchesPerOctave

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

.stepsPerOctave

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

but note:

.at(index)

.wrapAt(index)

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

==(that)

.checkTuningForMismatch(aTuning)

.degrees

.guessPPO

.hash

.name

.name = value

.octaveRatio

.performDegreeToKey(scaleDegree, stepsPerOctave, accidental: 0)

.performKeyToDegree(degree, stepsPerOctave: 12)

.performNearestInList(degree)

.performNearestInScale(degree, stepsPerOctave: 12)

Examples