[Haskell-cafe] help with musical data structures
Stephen Tetley
stephen.tetley at gmail.com
Sun Nov 15 06:55:28 EST 2009
2009/11/15 Henning Thielemann <lemming at henning-thielemann.de>:
> In Haskore there is a type for pitch classes:
>
> http://hackage.haskell.org/packages/archive/haskore/0.1/doc/html/Haskore-Basic-Pitch.html
> but maybe it is not what you need, since it distinguishes between C sharp
> and D flat and so on.
Hi Henning
The enharmonic doublings and existing Ord instance make Haskore's
PitchClass a tricky proposition for representing the Serialist's view
of pitch classes. An integer (or Z12) represent would be simpler.
To get pitch names I would recover them with a post-processing step,
spelling pitches with respect to a "scale" (here a SpellingMap):
> spell :: SpellingMap -> Pitch -> Pitch
The spell function returns the note in the scale (SpellingMap) if
present, otherwise it returns the original to be printed with an
accidental.
I have my own pitch representation, but a SpellingMap for Haskore would be
> type SpellingMap = Data.Map PitchClass PitchClass
Scales here are functions that generate SpellingMaps rather than
objects themselves.
The modes and major and minor scales have easy generation as they are
someways rotational over the circle of fifths (I've have implemented a
useful algorithm for this but can't readily describe it[1]). Hijaz and
klezmer fans need to construct their spelling maps by hand.
Best wishes
Stephen
[1] Code exists here - vis dependencies and scant documentation that
stop it being useful:
http://code.google.com/p/copperbox/source/browse/trunk/bala/Mullein/src/Mullein/Pitch.hs
More information about the Haskell-Cafe
mailing list