Class Scale

The Scale class defines the collection of pitches that make up a specific scale.

Hierarchy

  • Scale

Implements

Constructors

  • Parameters

    • template: ScaleTemplate

      The ScaleTemplate object which defines the scale type that this scale uses.

    • root: string | number

      The root of the scale. Can also take pitch names, see the pitch method for more information.

    Returns Scale

Accessors

  • get length(): number
  • How many pitches are in the scale.

    Returns number

  • get name(): string
  • The name of the scale

    Returns string

  • set name(value: string): void
  • Parameters

    • value: string

    Returns void

  • get pitches(): number[]
  • The pitches which make up the scale, ordered ascending by scale degree from the scale's root, with each pitch within the range 0 - 11.

    For example, the pitches collection for F major would be: [5, 7, 9, 10, 0, 2, 4]

    Returns number[]

  • get root(): number
  • The root pitch of the scale.

    Returns number

  • get typeName(): string
  • Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.

    Returns string

Methods

  • Returns true if the passed in pitch belongs to the scale. Can also take pitch names, see the pitch method for more information.

    For example:

    cMajor.contains(7) //returns true
    cMajor.contains('Db7') //returns false
    cMajor.contains('A8') //returns true

    Parameters

    • pitch: string | number

    Returns boolean

  • Returns the scale degree of the passed in pitch, or -1 if it's not contained. Can also take pitch names, see the pitch function for more information.

    Parameters

    • pitch: string | number

    Returns number

  • Returns a pitch near to the passed in pitch, but which should fit better with the notes within the scale.

    Returns

    Returns a new pitch number.

    Parameters

    • pitch: string | number

      The pitch which we want to fit to the scale. Can also take pitch names, see the pitch method for more information.

    • Optional options: Partial<FitPitchOptions>

      The options allow us to configure how we want the pitch to be fitted to the scale.

    Returns number

  • Returns a new Scale object whose root is 7 semi-tones above (or 5 semi-tones below) the root of the current scale.

    Returns Scale

  • Returns a new Scale object that is parallel to the current scale.

    For example, eMinor.getRelativeScale(shimi.ScaleTemplate.dorian) would return an E dorian scale.

    Returns

    Parameters

    • template: ScaleTemplate

      The template which we want the parallel scale to be of. If the calling scale already has that template, then the method just returns the calling scale object.

    Returns Scale

  • The degree method accepts a numerical scale degree, and returns the numerical pitch value which it corresponds to.

    Returns

    Parameters

    • degree: number

      The degree of the scale to fetch. This starts counting from root = 1.

      If degree is greater than scale.length, then how much higher it is will determine how many octaves it shifts up in its search. For example:

      cMajor.degree(3, 2)  //returns 40
      cMajor.degree(10, 2) //returns 52
      cMajor.degree(17, 2) //returns 64

      Similarly, if degree is less than 1, then how much lower it is will determine how many octaves it shifts down in its search.

    • rootOctave: number = -1

      The octave of the scale root, which the returned pitch is calculated in relation to.

    Returns number

  • Takes a numerical pitch value and returns a string representation of that pitch, that makes sense relative to the scale.

    For example:

    cMajor.getPitchName(7)      //returns 'G'
    cMajor.getPitchName('E') //returns 'E'
    cMinor.getPitchName('E') //returns 'E♮'

    Returns

    Parameters

    • pitch: string | number

      The pitch to get the string representation of. Can also take pitch names, see the pitch method for more information.

    • showOctave: boolean = false

      Whether to show a number after the name showing which octave we're in.

    Returns string

  • Returns a new Scale object that is relative to the current scale, according to how the template.relativityToMajor properties have been set up.

    For example, eMinor.getRelativeScale(shimi.ScaleTemplate.dorian) would return an A dorian scale.

    Returns

    Parameters

    • template: ScaleTemplate

      The template which we want the relative scale to be of. If the calling scale already has that template, then the method just returns the calling scale object.

    Returns Scale

  • Returns a new Scale object whose root is 5 semi-tones above (or 7 semi-tones below) the root of the calling scale.

    Returns Scale

  • Returns a new Scale object whose root is x semi-tones above or below the root of the calling scale.

    Parameters

    • transposition: number

    Returns Scale

  • The pitchesInRange method takes 2 numerical values, and returns all scale pitches which exist within that range. The search is inclusive of the passed in pitch parameters. Can also take pitch names, see the pitch method for more information.

    Note, if lowPitch > highPitch, then rather than throw an error, lowPitch & highPitch are swapped in their roles.

    Returns

    Parameters

    • lowPitch: string | number

      The low pitch to compare against.

    • highPitch: string | number

      The high pitch to compare against.

    Returns number[]

Generated using TypeDoc