HarmTrace-Base-1.4.0.1: Parsing and unambiguously representing musical chords.

Copyright(c) 2012--2014 W. Bas de Haas and Jose Pedro Magalhaes, Multiphonyx Holding BV
LicenseLGPL-3
Maintainerbas@chordify.net, dreixel@chordify.net
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

HarmTrace.Base.Chord.Datatypes

Contents

Description

Summary: A set of types and classes for representing musical chords. The chord datatypes are based on the unambiguous chord representation presented in: Christopher Harte, Mark Sandler and Samer Abdallah (2005), Symbolic representation of musical chords: a proposed syntax for text annotations, In: Proceedings of 6th International Conference on Music Information Retrieval (http://ismir2005.ismir.net/proceedings/1080.pdf).

Synopsis

Representing musical chords and keys

data Note a Source

A musical note is a pitch (either absolute or relative) possibly modified by an Accidental

Constructors

Note Accidental a 

data Accidental Source

A musical Accidental

Constructors

Nat

natural

Sh

sharp

Fl

flat

SS

double sharp

FF

double flat

type Root = Note DiatonicNatural Source

Representing absolute Root notes

type ScaleDegree = Note DiatonicDegree Source

Key relative scale degrees to abstract from the absolute Root notes

Keys

data Key Source

A musical key consising of a Root and Mode

Constructors

Key 

Fields

keyRoot :: Root
 
keyMode :: Mode
 

Instances

data Mode Source

The Mode of a key, which can be major or minor

Constructors

MajMode 
MinMode 

Chords

data Chord a Source

The representation for a single chord consisting of a root, a Shorthand representing the interval structure of the chord, a list of Additions, for representing other (additional) structure, and the base Inversion

Constructors

Chord a Shorthand [Addition] Interval

a regular chord

NoChord

No sounding chord (silence, noise, etc.)

UndefChord

An undefined chord

Instances

Functor Chord 
Show ChordLabel 
EnHarEq ChordLabel 
Eq a => Eq (Chord a) 
Ord a => Ord (Chord a) 
Generic (Chord a) 
Binary a => Binary (Chord a) 
type Rep (Chord a) 

chordRoot :: Show a => Chord a -> a Source

Returns the root of a Chord, and throws an error in case of a NoChord or an UndefChord.

chordShorthand :: Show a => Chord a -> Shorthand Source

Returns the Shorthand of a Chord, and throws an error in case of a NoChord or an UndefChord.

chordAdditions :: Show a => Chord a -> [Addition] Source

Returns the list of Additions of a Chord, and throws an error in case of a NoChord or an UndefChord.

chordBass :: Show a => Chord a -> Interval Source

Returns the bass Interval of a Chord, and throws an error in case of a NoChord or an UndefChord.

data Shorthand Source

Constructors

Maj

Triadic chords

Min 
Dim 
Aug 
Maj7

Seventh chords

Min7 
Sev 
Dim7 
HDim7 
MinMaj7 
Aug7 
Maj6

Sixth chords

Min6 
Nin

Extended chords

Maj9 
Min9 
Sus4

Suspended chords

Sus2 
SevSus4 
Five

Power chords

None 
Eleven 
Thirteen 
Min11 
Maj13 
Min13 

data Addition Source

Intervals for additional chord notes

Constructors

Add Interval 
NoAdd Interval 

data IntNat Source

Diatonic major intervals used to denote Chord Additions and bass Intervals

Constructors

I1 
I2 
I3 
I4 
I5 
I6 
I7 
I8 
I9 
I10 
I11 
I12 
I13 

type ChordLabel = Chord Root Source

A chord based on absolute Root notes

type ChordDegree = Chord ScaleDegree Source

A chord based on relative ScaleDegrees

Derived types for classification of chords

data ClassType Source

Updates the root field of a Chord updateRoot :: Chord a -> a -> Chord a updateRoot (Chord r sh a b) r' = Chord r' sh a b

We introduce four chord categories: major chords, minor chords, dominant seventh chords, and diminished seventh chords

data Triad Source

A Triad comes in four flavours: major, minor, augmented, diminished, and sometimes a chord does not have a triad (e.g. suspended chords, etc.)

Tests & Utilities

shortChord :: Root -> Shorthand -> ChordLabel Source

A Constructor for a simple chord based on a Root and Shorthand only

discardBass :: Chord a -> Chord a Source

Discards a base note by replacing the bass Interval by a Note Nat I1

isNoneChord :: ChordLabel -> Bool Source

Returns True if the ChordLabel is not a chord, and False otherwise

isAddition :: Addition -> Bool Source

Returns true if the Chord Addition represents an addition and not a degree that has to be removed (*).

catchNoChord :: Show a => String -> (Chord a -> b) -> Chord a -> b Source

Checks if the ChordLabel is a NoChord or UndefChord and throws an error using the first argument as an function identifier for debugging. In case of a ChordLabel the second argument is applied to the third argument.