Module

Harmonia.Chord

Package
purescript-harmonia
Repository
afcondon/purescript-harmonia

Harmonia.Chord — the harmonic vocabulary's recipe layer.

A DegreeChord is a scale-degree-relative chord recipe (numeral + quality

  • tensions + optional slash); realize :: Key -> DegreeChord -> Chord resolves it against a Key into a set of pitch classes (0..11). No voicing, no voice leading, no emit — those live in Harmonia.Voicing.

Design ground rules:

  • Slash, not inversion. First-inversion of a triad is just a slash with the 3rd as bass.
  • A chord can be arbitrary-size; polyphony budget is a sink concern.
  • Tensions are absolute (major / perfect) intervals from the chord root. Add 7 is the major 7th; for a minor-7 chord use the Min7 quality. Sharp n / Flat n shift the default by ±1. Sus n replaces the 3rd.
  • borrow Mode dc resolves the chord's root in a parallel mode (modal interchange); it only shifts the root lookup, not the tension arithmetic.

Pure Prelude/Data.* — no Effect, no FFI — so it compiles unchanged under the JS backend and purerl (Erlang). See Harmonia.Voicing for the concrete-pitch / voice-leading layer.

#DegreeChord Source

newtype DegreeChord

Constructors

Instances

#Key Source

type Key = { mode :: Mode, tonic :: Int }

#Chord Source

newtype Chord

Constructors

Instances

#numeralIndex Source

numeralIndex :: Numeral -> Int

Zero-based index into the mode's interval array.

#qualityIntervals Source

qualityIntervals :: Quality -> Array Int

Interval set of a chord quality, in semitones from the root.

#modeIntervals Source

modeIntervals :: Mode -> Array Int

Semitone offsets from the tonic for each scale degree.

#defaultIntervalFor Source

defaultIntervalFor :: Int -> Maybe Int

Default semitone offset for a numbered degree, measured from the chord root.

#realize Source

realize :: Key -> DegreeChord -> Chord

Resolve a DegreeChord against a Key.

#chordRoot Source

chordRoot :: Key -> DegreeChord -> Int

The chord's ROOT pitch class against a Key — (tonic + mode-interval at numeral) mod 12, honouring a borrowed-mode override. Same arithmetic realize uses for the root; exposed so callers can GROUND a chord (put its root in the bass) and LABEL it by its root rather than by the lowest pitch-class of a sorted voicing.

#chordBass Source

chordBass :: Key -> DegreeChord -> Int

The pitch class a chord should sit on in the bass: its slash bass if slashed (e.g. I maj7/vii), else its root.

#deg Source

deg :: Numeral -> Quality -> Array Tension -> DegreeChord

Convenience constructor: numeral + quality + tensions, default slash/mode to Nothing.

#slashed Source

slashed :: DegreeChord -> Numeral -> DegreeChord

Apply a slash bass to a chord recipe.

#borrow Source

borrow :: Mode -> DegreeChord -> DegreeChord

Borrow this chord's root lookup from a parallel mode.

#cMajorKey Source

#aMinorKey Source

#mcmullenYellowNames Source

mcmullenYellowNames :: Array String

Short display names, parallel (index-for-index) to mcmullenYellow.