UNPKG

shimi

Version:

A JS framework for building complex MIDI applications

95 lines (94 loc) 5.3 kB
import Scale from './Scale'; /** * The ScaleTemplate class represents a scale in abstract, before it has been associated with any specific root. It instead defines some of the qualities of any scale to be created from it. * * The expected usage of this is to use one of the pre-defined scale templates already provided to generate scale objects, for example: `shimi.ScaleTemplate.major.create(shimi.pitch('D'))` * * However, you can also use this class to define your own custom scale types, for example: * ``` * const myScaleType = new shimi.ScaleTemplate('James Minor', [0,2,3,5,7,8,9], -3); * const eJamesMinor = myScaleType.create(shimi.pitch('E')); * ``` * * @category Chords & Scales */ export default class ScaleTemplate { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** The name of the scale type, e.g. 'Major', 'Harmonic Minor', 'Phrygian', 'My Special Scale', etc. */ get name(): string; set name(value: string); private _name; /** * The shape property defines which notes make up a scale of this type. * * For example, the major scale would have shape [0,2,4,5,7,9,11], because when you create a major scale, it will have a note 2 semi-tones above the root, a note 4 semi-tones above the root, etc. */ get shape(): number[]; private _shape; /** * The relativityToMajor property is used by some of the functions for fetching related scales. For example, the natural minor scale would have relativityToMajor = -3 (or 9), because the root of the natural minor scale is expected to be 3 semi-tones below (or 9 above) the root of its relative major scale. Meanwhile Dorian would have relativityToMajor = 2. */ get relativityToMajor(): number; set relativityToMajor(value: number); private _relativityToMajor; /** * @param name The name of the scale type, e.g. 'Major', 'Harmonic Minor', 'Phrygian', 'My Special Scale', etc. * @param shape The shape property defines which notes make up a scale of this type. * * For example, the major scale would have shape [0,2,4,5,7,9,11], because when you create a major scale, it will have a note 2 semi-tones above the root, a note 4 semi-tones above the root, etc. * * If 0 is omitted from the shape, then it will automatically be added, so the above example could also be expressed as [2,4,5,7,9,11]. * @param relativityToMajor The relativityToMajor property is used by some of the functions for fetching related scales. For example, the natural minor scale would have relativityToMajor = -3 (or 9), because the root of the natural minor scale is expected to be 3 semi-tones below (or 9 above) the root of its relative major scale. Meanwhile Dorian would have relativityToMajor = 2. */ constructor(name: string, shape: number[], relativityToMajor: number); /** * Returns a new Scale object for a specific root, with properties inherited from the Template that created it. * @param root The root of the new Scale object. Can also take pitch names, see the [pitch](../functions/pitch.html) method for more information. * @returns */ create(root: number | string): Scale; /** The pre-defined major scale template. */ static get major(): ScaleTemplate; /** Same as ScaleTemplate.major, but more old school. */ static get ionian(): ScaleTemplate; private static _major; /** The pre-defined dorian scale template. */ static get dorian(): ScaleTemplate; private static _dorian; /** The pre-defined phrygian scale template. */ static get phrygian(): ScaleTemplate; private static _phrygian; /** The pre-defined lydian scale template. */ static get lydian(): ScaleTemplate; private static _lydian; /** The pre-defined mixolydian scale template. */ static get mixolydian(): ScaleTemplate; private static _mixolydian; /** The pre-defined natural minor scale template. */ static get naturalMinor(): ScaleTemplate; /** Same as ScaleTemplate.naturalMinor, but more old school. */ static get aeolian(): ScaleTemplate; private static _naturalMinor; /** The pre-defined harmonic minor scale template. */ static get harmonicMinor(): ScaleTemplate; private static _harmonicMinor; /** The pre-defined melodic minor scale template. Note, this is the jazz version of the scale, since shimi has no concept of scales being different when ascending vs descending. */ static get melodicMinor(): ScaleTemplate; private static _melodicMinor; /** The pre-defined locrian scale template. */ static get locrian(): ScaleTemplate; private static _locrian; /** The pre-defined major pentatonic scale template. */ static get majorPentatonic(): ScaleTemplate; private static _majorPentatonic; /** The pre-defined minor pentatonic scale template. */ static get minorPentatonic(): ScaleTemplate; private static _minorPentatonic; /** The pre-defined whole tone scale template. */ static get wholeTone(): ScaleTemplate; private static _wholeTone; /** The pre-defined diminished scale template. */ static get diminished(): ScaleTemplate; private static _diminished; }