require('sharp11').scale
Contains a Scale object, which can be created with scale.create()
, and a TraversableScale object, which can be created by calling .traverse()
on a Scale object. Methods of these objects do not mutate them, they return a new objects.
An object mapping scale names to arrays. Each array contains strings representing the intervals in the scale, not including the root.
An array of scale names in order of how commonly used they are. This order is used in the .scales()
method of the Chord object.
Returns a Scale object. key
is a Note object or string representing the key (or root) of the scale. scaleName
is a string containing the name of the scale. scaleName
is converted to lowercase and spaces are replaced with underscores. Sharp11 supports a wide variety of scales as well as aliases, so Superlocrian
, Altered
, and Diminished Whole Tone
will all work.
Returns true if an object is a Scale or a TraversableScale.
Returns true if a given object is a TraversableScale.
Scale
objects consist of a key and a scale name. A Scale
may or may not have octave numbers depending on whether or not the key
parameter does. Octave numbers behave as expected, so a major scale with a key of G4 will contain the notes G4, A4, B4, C5, D5, E5, F#5. The Scale
constructor is accessible directly as .Scale
, however new instances should be created using .create()
instead.
A Note object representing key of the scale.
A string representing the name of the scale (capitalized, spaces between words), e.g., "Harmonic Minor". .name
should not be used for comparing scales, because scale.create('minor')
and scale.create('natural minor')
will produce the same scale but with different .name
s.
A string representing the name of the scale (lowercase, underscores between words), e.g., "harmonic_minor" .id
s are one-to-one with scales and thus can be used for comparison.
A string representing the name of the scale including the key, e.g., "Bb Harmonic Minor".
The (optional) octave number of the scale, i.e., an integer between 0 and 9, or null
.
An array of Note objects representing the notes in the scale, e.g., [C, D, E, F, G, A, B]
An array of Interval objects representing the intervals in the scale, including the root.
Returns an array of Note objects representing the notes in the scale descending, starting with the root. .descending()
takes into account the abnormal nature of the melodic minor.
Applies note.clean()
to the key and all the notes in the scale.
Transposes the scale, applying note.transpose()
.
Calls .transpose(interval, true)
.
Returns a Note representing the nearest note on the scale to a given note (Note object or string). Octave numbers are ignored. If there are two nearest notes, the lower will be returned.
Returns true if the given note is in the scale, following the rules of note.containedIn()
.
Returns the scale in a given octave number.
Returns true if a given interval (Interval object or string) is in the scale.
Returns a TraversableScale whose current note is the given note (Note object or string). The given note must have an octave number.
TraversableScale
objects contain a scale and a current index and are created by calling .traverse()
on a Scale object. TraversableScale
s can be thought of as a combination of a note and a scale and allow you to easily traverse the scale, as the name implies. They are instrumental (pun intended) in Sharp11's improvisation engine. The TraversableScale
constructor is accessible directly as .TraversableScale
, however new instances should be created by calling .traverse()
on a Scale object instead.
A Scale object representing the scale.
The index of the scale's current note, starting at 0. .index
is mostly used internally, whereas .current()
returns the actual note.
Returns the octave number that the scale is currently in. This is the same as the octave number of the scale's root.
The number of notes in one octave of the scale, equal to .scale.scale.length
.
See .name
.
See .id
.
See .fullName
.
Returns a Note object representing the scale's current note.
See .clean()
.
See .transpose()
.
See .transposeDown()
.
Shifts the current note of the scale by a given number of positions, positive or negative. The resulting scale may have a different octave number depending on how far it has been shifted.
Shifts the current note of the scale by a given interval, applying note.transpose()
. The resulting scale may have a different octave number depending on how far it has been shifted. Throws an error if the transposed note is not in the scale.
Makes the current note of the scale a random note in the scale.
Makes the current note of the scale the given note (Note object or string).
See .nearest()
.
See .contains()
.
See .hasInterval()
.
See .descending()
.