duncanmalashock/elm-music-theory/1.0.0

Music.Chord

A chord is a set of pitch classes that are meant to be sounded together to create harmony. E.g. a "G dominant seventh" chord.

type alias Chord =
Chord

Helpers

chordType : Chord -> ChordType

Get a chord's type:

chordType (dominantSeventh PitchClass.a) == ChordType.dominantSeventh
root : Chord -> PitchClass

Get a chord's root:

root (dominantSeventh PitchClass.a) == PitchClass.a
containsPitchClass : PitchClass -> Chord -> Bool

Determine whether a chord contains a given pitch class:

containsPitchClass PitchClass.cSharp (major PitchClass.a) == True
detect : List ChordType -> List PitchClass -> List Chord

Detect chords that contain the given pitch classes:

detect
    [ ChordType.majorSix
    , ChordType.minorSeventh
    ]
    [ PitchClass.a
    , PitchClass.c
    , PitchClass.e
    , PitchClass.g
    ]
    == [ minorSeventh PitchClass.a
       , majorSix PitchClass.c
       ]

Passing in a list of chord types to detect is required, since there exists no exhaustive list of valid chords in tonal music.

Conversion

toPitchClasses : Chord -> List PitchClass

Get the pitch classes in a chord:

toPitchClasses (major PitchClass.a)
    == [ PitchClass.a
       , PitchClass.cSharp
       , PitchClass.e
       ]

Note: for converting a chord to pitches, I recommend looking at the functions in the Voicing chords section below.

toString : Chord -> String

Get the chord symbol for a chord:

toString (dominantNinth PitchClass.a) == "A9"

Looking for more flexibility? Look at ChordType.classify.

Voicing chords

A chord is defined by a set of pitch classes. But pitch classes can't be heard; only pitches can be. "Voicing" a chord is the process of:

  1. choosing some number of its pitch classes, and
  2. turning them into pitches within specific octaves, so that they can be played or sung.

Learn more about how this works in the Voicing.ThreePart, Voicing.FourPart, and Voicing.FivePart modules.

{ voiceOne : Range
, voiceTwo : Range
, voiceThree : Range
}
-> List VoicingMethod
-> Chord
-> List Voicing
{ voiceOne : Range
, voiceTwo : Range
, voiceThree : Range
, voiceFour : Range
}
-> List VoicingMethod
-> Chord
-> List Voicing
{ voiceOne : Range
, voiceTwo : Range
, voiceThree : Range
, voiceFour : Range
, voiceFive : Range
}
-> List VoicingMethod
-> Chord
-> List Voicing

Constructors

Triads

major : PitchClass -> Chord
minor : PitchClass -> Chord
augmented : PitchClass -> Chord
diminished : PitchClass -> Chord
sus2 : PitchClass -> Chord
sus4 : PitchClass -> Chord

Added-tone chords

majorSix : PitchClass -> Chord
majorSixNine : PitchClass -> Chord
minorSix : PitchClass -> Chord
minorSixNine : PitchClass -> Chord
majorAddNine : PitchClass -> Chord
minorAddNine : PitchClass -> Chord

Seventh chords

majorSeventh : PitchClass -> Chord
majorSeventhSharpEleven : PitchClass -> Chord
minorSeventh : PitchClass -> Chord
dominantSeventh : PitchClass -> Chord
diminishedSeventh : PitchClass -> Chord
halfDiminished : PitchClass -> Chord
augmentedDominantSeventh : PitchClass -> Chord
dominantSeventhSus4 : PitchClass -> Chord
minorMajorSeventh : PitchClass -> Chord

Chords with extensions

majorNinth : PitchClass -> Chord
minorNinth : PitchClass -> Chord
dominantNinth : PitchClass -> Chord
minorEleventh : PitchClass -> Chord
dominantEleventh : PitchClass -> Chord
dominantThirteenth : PitchClass -> Chord

Altered dominant chords

Seventh

dominantSeventhFlatNine : PitchClass -> Chord
dominantSeventhSharpNine : PitchClass -> Chord
dominantSeventhFlatNineSharpNine : PitchClass -> Chord
dominantSeventhSharpEleven : PitchClass -> Chord
dominantSeventhFlatThirteen : PitchClass -> Chord

Ninth

dominantNinthSharpEleven : PitchClass -> Chord
dominantNinthFlatThirteen : PitchClass -> Chord

Thirteenth

dominantThirteenthFlatNine : PitchClass -> Chord
dominantThirteenthSharpNine : PitchClass -> Chord
dominantThirteenthSharpEleven : PitchClass -> Chord

Custom chord types

custom : PitchClass -> ChordType -> Chord

Create a chord from a custom chord type. For use with ChordType.custom:

myCustomChordType =
    ChordType.custom
        |> ChordType.withMinorThird
        |> ChordType.withDiminishedFifth
        |> ChordType.withMinorSeventh


myCustomChord =
    |> custom PitchClass.c myCustomChordType


-- Equivalent to `halfDiminishedSeventh PitchClass.c`

You can also use custom to construct a chord from a chord type, in cases where the chord type may vary:

custom PitchClass.c ChordType.majorSeventh
    == Chord.majorSeventh PitchClass.c