duncanmalashock / elm-music-theory / Music.ChordType

A chord type describes the factors contained in a chord, with no specific root pitch class. E.g. a "dominant seventh" chord.


type alias ChordType =
Music.Internal.ChordType.ChordType

Chord factors

Chord factors (such as the "third", "fifth", etc. of a chord) are represented as Intervals.

factors : ChordType -> List Music.Internal.Interval.Interval

Get the factors contained in a chord type:

factors minor
    == [ Interval.perfectUnison
       , Interval.minorThird
       , Interval.perfectFifth
       ]

contains : Music.Internal.Interval.Interval -> Music.Internal.ChordType.ChordType -> Basics.Bool

Determine whether a chord type contains a given factor:

contains Interval.diminishedFifth halfDiminishedSeventh == True

Categorizing factors

Categorize factors into certain useful data structures. Helpful when creating custom voicing methods.

categorizeFactors : ChordType -> Maybe CategorizedFactors

Categorize the factors in a chord type:

categorizeFactors minorSix
    == { third = Interval.minorThird
       , fifth = Interval.perfectFifth
       , sixthOrSeventh = Just Interval.majorSixth
       , ninth = []
       , eleventh = Nothing
       , thirteenth = Nothing
       }


type alias CategorizedFactors =
{ third : Music.Internal.Interval.Interval
, fifth : Music.Internal.Interval.Interval
, sixthOrSeventh : Maybe Music.Internal.Interval.Interval
, ninth : List Music.Internal.Interval.Interval
, eleventh : Maybe Music.Internal.Interval.Interval
, thirteenth : Maybe Music.Internal.Interval.Interval 
}

availableTensions : ChordType -> Maybe AvailableTensions

Organize the factors in a chord type into their jazz-theory category and their possible substitutes, often known referred to as "available tensions".

availableTensions majorSeventh =
    { root =
        { true = Interval.perfectUnison
        , substitutes = [ Interval.majorSecond ]
        }
    , third =
        { true = Interval.majorThird
        , substitutes = []
        }
    , fifth =
        { true = Interval.perfectFifth
        , substitutes = []
        }
    , seventh =
        { true = Interval.majorSeventh
        , substitutes = []
        }
    }


type alias AvailableTensions =
{ root : { true : Music.Internal.Interval.Interval
, substitutes : List Music.Internal.Interval.Interval }
, third : { true : Music.Internal.Interval.Interval
, substitutes : List Music.Internal.Interval.Interval }
, fifth : { true : Music.Internal.Interval.Interval
, substitutes : List Music.Internal.Interval.Interval }
, seventh : { true : Music.Internal.Interval.Interval
, substitutes : List Music.Internal.Interval.Interval } 
}

Conversion

toString : ChordType -> String

Get the chord symbol for a chord type:

toString majorSeventh == "M7"

Want more control over chord symbols? See the classify function.

Groups

Lists of commonly-grouped chord types. Note that these are incomplete, and only represent the chord types contained in this module, since there is no exhaustive list of all valid chord types in tonal music.

all : List ChordType

All the chord types listed in this module.

triads : List ChordType

All chord types with only a root, third (or suspension), and fifth.

sixthAndSeventhChords : List ChordType

All chord types with a sixth or seventh added to a triad.

majorChords : List ChordType

All chord types with a major quality.

minorChords : List ChordType

All chord types with a minor quality.

dominantChords : List ChordType

All chord types with a dominant quality.

alteredDominantChords : List ChordType

All chord types with a dominant quality that also have altered extensions.

Constructors

Triads

major : ChordType

minor : ChordType

augmented : ChordType

diminished : ChordType

sus2 : ChordType

sus4 : ChordType

Added-tone chords

majorSix : ChordType

majorSixNine : ChordType

minorSix : ChordType

minorSixNine : ChordType

majorAddNine : ChordType

minorAddNine : ChordType

Seventh chords

majorSeventh : ChordType

majorSeventhSharpEleven : ChordType

minorSeventh : ChordType

dominantSeventh : ChordType

diminishedSeventh : ChordType

halfDiminishedSeventh : ChordType

augmentedDominantSeventh : ChordType

dominantSeventhSus4 : ChordType

minorMajorSeventh : ChordType

Chords with extensions

majorNinth : ChordType

minorNinth : ChordType

dominantNinth : ChordType

minorEleventh : ChordType

dominantEleventh : ChordType

dominantThirteenth : ChordType

Altered dominant chords

Seventh

dominantSeventhFlatNine : ChordType

dominantSeventhSharpNine : ChordType

dominantSeventhFlatNineSharpNine : ChordType

dominantSeventhFlatNineSharpEleven : ChordType

dominantSeventhSharpNineSharpEleven : ChordType

dominantSeventhSharpEleven : ChordType

dominantSeventhFlatNineFlatThirteen : ChordType

dominantSeventhSharpNineFlatThirteen : ChordType

dominantSeventhSharpElevenFlatThirteen : ChordType

dominantSeventhFlatThirteen : ChordType

Ninth

dominantNinthSharpEleven : ChordType

dominantNinthFlatThirteen : ChordType

dominantNinthSharpElevenFlatThirteen : ChordType

Thirteenth

dominantThirteenthFlatNine : ChordType

dominantThirteenthSharpNine : ChordType

dominantThirteenthFlatNineSharpNine : ChordType

dominantThirteenthFlatNineSharpEleven : ChordType

dominantThirteenthSharpNineSharpEleven : ChordType

dominantThirteenthSharpEleven : ChordType

Custom chord types

custom : ChordType

Define a custom chord type. Start with custom and apply the chord factor functions below:

custom
    |> withMinorThird
    |> withDiminishedFifth
    |> withMinorSeventh
-- equivalent to `halfDiminishedSeventh`

Note: because there is no unified model for naming any given chord, your custom chord may not work with the toString function in this module.

withMajorThird : ChordType -> ChordType

withMinorThird : ChordType -> ChordType

withSuspendedSecond : ChordType -> ChordType

withSuspendedFourth : ChordType -> ChordType

withFifth : ChordType -> ChordType

withSharpFifth : ChordType -> ChordType

withFlatFifth : ChordType -> ChordType

withSixth : ChordType -> ChordType

withMajorSeventh : ChordType -> ChordType

withMinorSeventh : ChordType -> ChordType

withDiminishedSeventh : ChordType -> ChordType

withNinth : ChordType -> ChordType

withSharpNinth : ChordType -> ChordType

withFlatNinth : ChordType -> ChordType

withEleventh : ChordType -> ChordType

withSharpEleventh : ChordType -> ChordType

withThirteenth : ChordType -> ChordType

withFlatThirteenth : ChordType -> ChordType

Custom chord symbols

classify : ChordType -> Music.Chord.Classification.Classification

Get a chord type's classification:

classify dominantNinthFlatThirteen
    == Classification MajorTriad (Just MinorSeventh) Ninth [ MinorThirteenth ]

You can read more about how to use the Classification type in the Chord.Classification module.