Copyright | (c) Dima Szamozvancev |
---|---|
License | MIT |
Maintainer | ds709@cam.ac.uk |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Algebraic description of music with type-level constraints.
- data Music :: forall n l. Partiture n l -> Type where
- Note :: NoteConstraints r d => Root r -> Dur d -> Music (FromRoot r d)
- Rest :: RestConstraints d => Dur d -> Music (FromSilence d)
- (:|:) :: MelConstraints m1 m2 => Music m1 -> Music m2 -> Music (m1 +|+ m2)
- (:-:) :: HarmConstraints m1 m2 => Music m1 -> Music m2 -> Music (m1 +-+ m2)
- Chord :: ChordConstraints c d => Cho c -> Dur d -> Music (FromChord c d)
- data Score = Score (Music m)
- type Progression p d = Music (ChordsToPartiture (PieceToChords l p) d)
- type MelConstraints m1 m2 = IfStrict (ValidMelConcat m1 m2)
- type HarmConstraints m1 m2 = IfStrict (ValidHarmConcat (Align m1 m2))
- type ChordConstraints c d = (IntListRep c, Primitive n, Primitive d)
Music
data Music :: forall n l. Partiture n l -> Type where Source #
A piece of music consisting of parallel and sequential composition of notes and rests, subject to constraints.
Currently enforced constraints are:
- Height (number of voices) of two sequentially composed pieces must be equal.
- Width (number of temporal units) of two parallelly composed pieces must be equal.
- Sequentially composed voices cannot have any augmented, diminished or seventh leaps.
- Parallelly composed pieces cannot have any minor second or major seventh harmonic intervals.
- Music must not contain parallel or concealed unisons, fifths or octaves.
Note :: NoteConstraints r d => Root r -> Dur d -> Music (FromRoot r d) | A note specified by a pitch and a duration. |
Rest :: RestConstraints d => Dur d -> Music (FromSilence d) | A rest specified by a duration. |
(:|:) :: MelConstraints m1 m2 => Music m1 -> Music m2 -> Music (m1 +|+ m2) infixl 4 | Sequential or melodic composition of music. |
(:-:) :: HarmConstraints m1 m2 => Music m1 -> Music m2 -> Music (m1 +-+ m2) infixl 4 | Parallel or harmonic composition of music. |
Chord :: ChordConstraints c d => Cho c -> Dur d -> Music (FromChord c d) | A chord specified by a chord type and a duration. |
Harmonic constructs
type Progression p d = Music (ChordsToPartiture (PieceToChords l p) d) Source #
A chord progression with the given scheme and chord length.
Constraints
type MelConstraints m1 m2 = IfStrict (ValidMelConcat m1 m2) Source #
Ensures that two pieces of music can be composed sequentially.
type HarmConstraints m1 m2 = IfStrict (ValidHarmConcat (Align m1 m2)) Source #
Ensures that two pieces of music can be composed in parallel.
type ChordConstraints c d = (IntListRep c, Primitive n, Primitive d) Source #
Ensures that the chord is valid.