for PureScript & purerl

harmonia

Symbolic manipulation of musical structure — informed by theory, never prescriptive.

one line, three modes  ·  reflavoured

Ionian C · F · G · C lucent
Mixolydian C · F · Gm · C amber
Aeolian Cm · Fm · Gm · Cm shadow

One progression — I · IV · V · I — named once by degree. reflavour bends the mode; the tune keeps its shape, the light changes.

harmonia is a small, pure PureScript library for functional harmony. You name a chord by a scale degree, a quality, a tension, maybe a borrowed mode — and it realizes that recipe against a key into pitch classes, then threads a whole progression together by smallest motion. No Effect, no FFI; the same code compiles unchanged on JavaScript and on Erlang.

The three staves above are one call apart. Written once as scale degrees, the progression is handed to reflavour — and every chord re-derives its quality from the new mode’s own harmony. The four movements below go deeper; each carries the PureScript that makes it.

A

cantabile

The voices lead

block — root position, leaping
voice-led — least motion

The same ii–V–I, voiced two ways. Block-voiced, the chords leap. voiceLead instead moves to each next chord by the least total motion: every common tone stays on its exact pitch and each remaining voice steps to its nearest octave — so the whole progression barely moves.

B

campanae

A line, shadowed — tintinnabuli

the melody — M-voice
+ its shadow — T-voice

Arvo Pärt’s tintinnabuli (little bells): a melody moving stepwise, shadowed by a second voice that sounds only the notes of the home triad. Each shadow note is the melody note snapped to the nearest triad tone above — a pure map over the line.

C

poco a poco

The turnaround, enriched

triads — C · Am · Dm · G
+ sevenths — Cmaj7 · Am7 · Dm7 · G7
+ ninths — Cmaj9 · Am9 · Dm9 · G9

One functional skeleton — I · vi · ii · V — read three ways. Each pass names a richer recipe: add a seventh, add a ninth. The progression never changes; only its Quality and Tension do, and the chord grows a note at a time.

Fine.

to play — spago install harmonia

Engraved in the browser with Verovio · MIT · Andrew Condon