Copyright | (c) Dima Szamozvancev |
---|---|
License | MIT |
Maintainer | ds709@cam.ac.uk |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Types and constraints encoding the rules of classical music.
- class ValidMelConcat ps1 ps2
- class ValidHarmConcat ps
- class ValidHomConcat ps
- class ValidPitch p
- type family ValidMotion (p1 :: PitchType) (p2 :: PitchType) (q1 :: PitchType) (q2 :: PitchType) :: Constraint where ...
Documentation
class ValidMelConcat ps1 ps2 Source #
Ensures that two partitures can be horizontally concatenated.
Two part lists can be horizontally concatenated if
- both of them are empty or
- all of the voices can be appended.
class ValidHarmConcat ps Source #
Ensures that two partitures can be vertically concatenated.
Two partitures can be vertically concatenated if
- the top one is empty or
- all but the first voice can be concatenated, and the first voice forms valid harmonic dyads with every other voice and follows the rules of valid harmonic motion.
(ValidHarmConcat ((-) n1 1) n2 l ((,) (Partiture ((-) n1 1) l) (Partiture n2 l) vs us), AllSatisfyAll n2 (Voice l) ((:) (Voice l -> Constraint) (ValidHarmDyadsInVectors l v) ((:) (Voice l -> Constraint) (ValidHarmMotionInVectors l l v) ([] (Voice l -> Constraint)))) us) => ValidHarmConcat n1 n2 l ((,) (Vector (Voice l) n1) (Partiture n2 l) ((:--) (Voice l) n1 v vs) us) Source # | |
ValidHarmConcat 0 n2 l ((,) (Vector (OptVector PitchType l) 0) (Partiture n2 l) (None (OptVector PitchType l)) vs) Source # | |
class ValidHomConcat ps Source #
Ensures that two partitures can be vertically concatenated.
Two partitures can be vertically concatenated if
- the top one is empty or
- all but the first voice can be concatenated, and the first voice forms valid harmonic dyads with every other voice and follows the rules of valid harmonic motion.
(ValidHomConcat ((-) n1 1) n2 l ((,) (Partiture ((-) n1 1) l) (Partiture n2 l) vs us), AllSatisfyAll n2 (Voice l) ((:) (Voice l -> Constraint) (ValidHarmDyadsInVectors l v) ([] (Voice l -> Constraint))) us) => ValidHomConcat n1 n2 l ((,) (Vector (Voice l) n1) (Partiture n2 l) ((:--) (Voice l) n1 v vs) us) Source # | |
ValidHomConcat 0 n2 l ((,) (Vector (OptVector PitchType l) 0) (Partiture n2 l) (None (OptVector PitchType l)) vs) Source # | |
class ValidPitch p Source #
ValidPitch p Source # | |
PitchError Constraint "Note can't be lower than C natural of octave -1: " (Pitch C Flat Oct_1) => ValidPitch (Pitch C Flat Oct_1) Source # | |
PitchError Constraint "Note can't be higher than B natural of octave 8: " (Pitch B Sharp Oct8) => ValidPitch (Pitch B Sharp Oct8) Source # | |
type family ValidMotion (p1 :: PitchType) (p2 :: PitchType) (q1 :: PitchType) (q2 :: PitchType) :: Constraint where ... Source #
Ensures that four pitches (representing two consequent intervals) follow the rules for valid harmonic motion.
Harmonic motion is not permitted if
- it is direct motion into a perfect interval (this covers parallel and concealed fifths, octaves and unisons).
ValidMotion Silence _ _ _ = Valid | |
ValidMotion _ Silence _ _ = Valid | |
ValidMotion _ _ Silence _ = Valid | |
ValidMotion _ _ _ Silence = Valid | |
ValidMotion p1 p2 q1 q2 = If ((p1 .~. q1) .||. (p2 .~. q2)) (ObliqueMotion (MakeInterval p1 p2) (MakeInterval q1 q2)) (If (p1 <<? q1) (If (p2 <<? q2) (DirectMotion (DyPair p1 p2 q1 q2) (MakeInterval p1 p2) (MakeInterval q1 q2)) (ContraryMotion (MakeInterval p1 p2) (MakeInterval q1 q2))) (If (p2 <<? q2) (ContraryMotion (MakeInterval p1 p2) (MakeInterval q1 q2)) (DirectMotion (DyPair p1 p2 q1 q2) (MakeInterval p1 p2) (MakeInterval q1 q2)))) |