duncanmalashock/elm-music-theory/1.0.0

Music.Scale

A scale is a set of pitch classes in a certain order. E.g. the "C major scale."

type alias Scale =
Scale

Helpers

root : Scale -> PitchClass

Get the root pitch class of a scale:

root (major PitchClass.eFlat) == PitchClass.eFlat
scaleType : Scale -> ScaleType

Get the scale type for a scale:

scaleType (lydian PitchClass.c) == ScaleType.lydian
toList : Scale -> List PitchClass

Get the pitch classes contained in the scale:

toList (major PitchClass.f)
    == [ PitchClass.f
       , PitchClass.g
       , PitchClass.a
       , PitchClass.bFlat
       , PitchClass.c
       , PitchClass.d
       , PitchClass.e
       ]
containsPitchClass : PitchClass -> { ignoreSpelling : Bool } -> Scale -> Bool

Find out whether a scale contains a given pitch class:

containsPitchClass PitchClass.f
    { ignoreSpelling = False }
    (major PitchClass.c)
    == True

Set the ignoreSpelling flag to allow enharmonic equivalents. This returns True because G♭ is not in C Lydian, but F♯ (an equivalent) is:

containsPitchClass PitchClass.gFlat
    { ignoreSpelling = True }
    (lydian PitchClass.c)
    == True
containsChord : Chord -> Scale -> Bool

Find out whether a scale contains a given chord:

containsChord (Chord.majorSeventhSharpEleven PitchClass.f)
    (major PitchClass.c)
    == True
allChords : List ChordType -> Scale -> List Chord

Get all chords contained in a scale, choosing from a list of chord types to detect:

allChords [ ChordType.minorSeventh ] (major PitchClass.c)
    == [ Chord.minorSeventh PitchClass.d
       , Chord.minorSeventh PitchClass.e
       , Chord.minorSeventh PitchClass.a
       ]
degree : Int -> Scale -> PitchClass

Get a degree of the scale:

degree 3 (major PitchClass.c) == PitchClass.e

Note: like many numbers in music theory, degrees are 1-based; 2 means the second degree of the scale. 0 and negative integers are ignored.

mode : Int -> Scale -> Scale

Get a mode of a scale by shifting the order of its pitch classes. For example, E Phrygian is the third mode of the C major scale:

mode 3 (major PitchClass.c) == phrygian PitchClass.e

Note: like many numbers in music theory, modes are 1-based; 2 means the second mode of the scale type. 0 and negative integers are ignored.

Constructors

major : PitchClass -> Scale

Same as ionian

minor : PitchClass -> Scale

Also known as the "natural minor" scale. Same as aeolian

Modes of the major scale

ionian : PitchClass -> Scale
dorian : PitchClass -> Scale
phrygian : PitchClass -> Scale
lydian : PitchClass -> Scale
mixolydian : PitchClass -> Scale
aeolian : PitchClass -> Scale
locrian : PitchClass -> Scale

Modes of the melodic minor scale

melodicMinor : PitchClass -> Scale
dorianFlat2 : PitchClass -> Scale
lydianAugmented : PitchClass -> Scale
acoustic : PitchClass -> Scale
majorMinor : PitchClass -> Scale
minorLocrian : PitchClass -> Scale
superlocrian : PitchClass -> Scale

Modes of the harmonic minor scale

harmonicMinor : PitchClass -> Scale
locrianNatural6 : PitchClass -> Scale
majorAugmented : PitchClass -> Scale
lydianDiminished : PitchClass -> Scale
phrygianDominant : PitchClass -> Scale
aeolianHarmonic : PitchClass -> Scale
ultralocrian : PitchClass -> Scale

Symmetrical scales

diminishedWholeToneHalfTone : PitchClass -> Scale
diminishedHalfToneWholeTone : PitchClass -> Scale
wholeTone : PitchClass -> Scale

Pentatonic scales

majorPentatonic : PitchClass -> Scale
minorPentatonic : PitchClass -> Scale

Custom scales

custom : PitchClass -> ScaleType -> Scale

Create a scale from a custom scale type. For use with ScaleType.customPentatonic, ScaleType.customHexatonic, ScaleType.customHeptatonic, and ScaleType.customOctatonic:

myCustomScaleType =
    customPentatonic
        { rootToSecond = Interval.minorThird
        , rootToThird = Interval.perfectFourth
        , rootToFourth = Interval.perfectFifth
        , rootToFifth = Interval.minorSeventh
        }


myCustomScale =
    |> custom PitchClass.c myCustomScaleType


-- Equivalent to `minorPentatonic PitchClass.c`