Options
All
  • Public
  • Public/Protected
  • All
Menu

Scales consist of a key(tonic or root) and a template(array of integers) that
represents the interval of steps between each note.

Scale intervals are represented by an integer
that is the number of semitones between each note.
0 = key - will always represent the tonic
1 = half step
2 = whole step
3 = one and one half steps
4 = double step
[0, 2, 2, 1, 2, 2, 2] represents the major scale

Scale templates may have arbitray lengths

The following Pre-defined templates are available:

major minor ionian dorian
phrygian lydian mixolydian aeolian
locrian enigmaticMajor enigmaticMinor minor7b5
major7s4s5 harmonicMajor harmonicMinor doubleHarmonic
melodicMinorAscending melodicMinorDescending majorPentatonic majorPentatonicBlues
minorPentatonic minorPentatonicBlues b5Pentatonic minor6Pentatonic
dim8Tone dom8Tone neopolitanMajor neopolitanMinor
hungarianMajor hungarianMinor hungarianGypsy spanish
spanish8Tone spanishGypsy augmented dominantSuspended
bebopMajor bebopDominant mystic overtone
leadingTone hirojoshi japaneseA japaneseB
oriental arabian persian balinese
kumoi pelog algerian chinese
mongolian egyptian hindu romanian
hindu insen iwato scottish
yo istrian ukranianDorian petrushka
ahavaraba halfDiminished jewish byzantine
acoustic
example
import {Scale} from 'musictheoryjs';
import {ScaleTemplates} from 'musictheoryjs';
import {ScaleInitializer} from 'musictheoryjs'; // TypeScript only if needed

Hierarchy

  • Scale

Implements

  • Entity

Index

Constructors

constructor

  • example
    import {Scale, ScaleTemplates} from 'musictheoryjs';

    // creates a scale with the default template, key 0f 0(C) and an octave of 4
    const scale = new Scale();

    // creates a scale with the template [0, 2, 2, 1, 2, 2, 2] and key 4(E) and octave 5
    const scale2 = new Scale({key: 4, octave: 5, template: ScaleTemplates.major});


    // String parsing should follow the format: note-name[alteration][octave][(scale-name)]
    // creates a scale with the minor template, key Gb and an octave of 7
    const scale3 = new Scale('Gb7(minor)');

    Parameters

    Returns Scale

Properties

id

id: string = ...

unique id for this scale(auto generated)

example
const scale = new Scale();
console.log(scale.id); // dhlkj5j322

Accessors

key

  • example
    const scale = new Scale();
    console.log(scale.key); // 0(semitone)

    Returns Semitone

  • Setting the semitone to a value outside of the range 0, 11 will
    wrap the semitone to the range [0, 11] and change the octave depending
    on how many times the semitone has been wrapped.

    example
    const scale = new Scale();
    scale.key = 4;
    console.log(scale.key); // 4

    Parameters

    Returns void

notes

  • will generate the notes if needed or return the cached notes

    example
    const scale = new Scale();
    console.log(scale.notes); // List of notes

    Returns Note[]

octave

  • get octave(): number
  • set octave(value: number): void
  • The octave is clamped to the range [0, 9].

    example
    const scale = new Scale();
    console.log(scale.octave); // 4

    Returns number

  • The octave is clamped to the range [0, 9].

    example
    const scale = new Scale();
    scale.octave = 5;
    console.log(scale.octave); // 5

    Parameters

    • value: number

    Returns void

template

  • get template(): number[]
  • set template(value: number[]): void
  • example
    const scale = new Scale();
    console.log(scale.template); // [0, 2, 2, 1, 2, 2, 2]

    Returns number[]

  • The following Pre-defined templates are available:

    major minor ionian dorian
    phrygian lydian mixolydian aeolian
    locrian enigmaticMajor enigmaticMinor minor7b5
    major7s4s5 harmonicMajor harmonicMinor doubleHarmonic
    melodicMinorAscending melodicMinorDescending majorPentatonic majorPentatonicBlues
    minorPentatonic minorPentatonicBlues b5Pentatonic minor6Pentatonic
    dim8Tone dom8Tone neopolitanMajor neopolitanMinor
    hungarianMajor hungarianMinor hungarianGypsy spanish
    spanish8Tone spanishGypsy augmented dominantSuspended
    bebopMajor bebopDominant mystic overtone
    leadingTone hirojoshi japaneseA japaneseB
    oriental arabian persian balinese
    kumoi pelog algerian chinese
    mongolian egyptian hindu romanian
    hindu insen iwato scottish
    yo istrian ukranianDorian petrushka
    ahavaraba halfDiminished jewish byzantine
    acoustic
    example
    const scale = new Scale();
    scale.template = [0, 2, 2, 1, 2, 2, 2];
    console.log(scale.template); // [0, 2, 2, 1, 2, 2, 2]

    Parameters

    • value: number[]

    Returns void

Methods

aeolian

  • chainable
    example
    const scale = new Scale();
    console.log(scale.aeolian()); // Scale(copy)

    Returns Scale

    a copy of this scale in the Aeolian(minor) mode

copy

  • Returns a copy of this Scale

    chainable
    example
    const scale = new Scale();
    const scale2 = scale.copy();
    console.log(scale.equals(scale2)); // true

    Returns Scale

    a copy of this Scale

degree

  • degree(degree: number): Note
  • degree returns a note that represents the given degree

    example
    const scale = new Scale();
    console.log(scale.degree(0)); // C4(Note)
    console.log(scale.degree(1)); // D4(Note) etc

    Parameters

    • degree: number

      the degree to return

    Returns Note

    a note that represents the given degree

dorian

  • chainable
    example
    const scale = new Scale();
    console.log(scale.dorian()); // Scale(copy)

    Returns Scale

    a copy of this scale in the Dorian mode

equals

  • equals(scale: Scale): boolean
  • Returns true if this scale is equal to the given scale

    example
    const scale = new Scale();
    const scale2 = new Scale();
    console.log(scale.equals(scale2)); // true

    Parameters

    • scale: Scale

      the scale to compare to

    Returns boolean

    true if the scales are equal

getNoteNames

  • getNoteNames(preferSharpKey?: boolean): string[]
  • returns the names of the notes in the scale

    example
    const scale = new Scale();
    console.log(scale.names); // ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4']

    Parameters

    • preferSharpKey: boolean = true

    Returns string[]

    the names of the notes in the scale

ionian

  • chainable
    example
    const scale = new Scale();
    console.log(scale.ionian()); // Scale(copy)

    Returns Scale

    a copy of this scale in the Ionian(major) mode

locrian

  • chainable
    example
    const scale = new Scale();
    console.log(scale.locrian()); // Scale(copy)

    Returns Scale

    a copy of this scale in the Locrian mode

lydian

  • chainable
    example
    const scale = new Scale();
    console.log(scale.lydian()); // Scale(copy)

    Returns Scale

    a copy of this scale in the Lydian mode

mixolydian

  • chainable
    example
    const scale = new Scale();
    console.log(scale.mixolydian()); // Scale(copy)

    Returns Scale

    a copy of this scale in the Mixolydian mode

phrygian

  • chainable
    example
    const scale = new Scale();
    console.log(scale.phrygian()); // Scale(copy)

    Returns Scale

    a copy of this scale in the Phrygian mode

relativeMajor

  • relative major returns a new scale that is the relative major of this scale - takes the 3rd degree as it's key

    chainable
    example
    const scale = new Scale();
    console.log(scale.relativeMajor()); // Scale

    Returns Scale

    a new scale that is the relative major of this scale

relativeMinor

  • relative minor returns a new scale that is the relative minor of this scale - takes the 6th degree as it's key

    chainable
    example
    const scale = new Scale();
    console.log(scale.relativeMinor()); // Scale

    Returns Scale

    a new scale that is the relative minor of this scale

shift

  • shift(degrees?: number): Scale
  • shift shifts the scale by the given number of degrees

    chainable
    example
    const scale = new Scale();
    console.log(scale.shift(1)); // Scale

    Parameters

    • degrees: number = 1

    Returns Scale

    a new scale that is the shifted scale

shifted

  • shifted(degrees?: number): Scale
  • shifted returns a copy of this scale shifted by the given number of degrees

    chainable
    example
    const scale = new Scale();
    console.log(scale.shifted(1)); // Scale(copy)

    Parameters

    • degrees: number = 1

      the number of degrees to shift the scale

    Returns Scale

    a copy of this scale shifted by the given number of degrees

shiftedInterval

  • shiftedInterval(): number
  • returns the amount that the scale has shifted (0 if not shifted)

    example
    const scale = new Scale();
    console.log(scale.shift(1));
    console.log(scale.shifted()); // 1

    Returns number

    the amount that the scale has shifted (0 if not shifted)

toString

  • toString(): string
  • returns string version of the scale

    example
    const scale = new Scale();
    console.log(scale.toString()); // 'C'

    Returns string

    string version of the scale

unshift

  • unshift shifts the original root back to the root position

    chainable
    example
    const scale = new Scale();
    console.log(scale.shift(1));
    console.log(scale.unshift());

    Returns Scale

    this scale after unshifting it back to the original root position

unshifted

  • unshifted returns a copy of this scale with the tonic shifted back to the root position

    chainable
    example
    const scale = new Scale();
    console.log(scale.shift(1));
    console.log(scale.unshifted()); // Scale(copy)

    Returns Scale

    a copy of this scale with the tonic shifted back to the root position

Generated using TypeDoc