Created
March 25, 2014 14:11
-
-
Save meditans/9762657 to your computer and use it in GitHub Desktop.
Interval analysis of a Cantus firmus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Music.Prelude.Basic hiding (Interval) | |
import Music.Pitch.Common.Interval (Interval) | |
main :: IO () | |
main = openLilypond . showAnnotations' "" | |
. intervalAnnotations subjectDiff | |
. scat $ map reify subject | |
subject :: [BasicPitch] | |
subject = [c, d, f, e, f, g, a, g, e, d, c] | |
subjectDiff :: [Interval] | |
subjectDiff = zipWith (.-.) (tail subject) subject | |
reify :: BasicPitch -> Score BasicNote | |
reify = (`up` c) . (.-. c) | |
intervalAnnotations :: [Interval] -> (Score BasicNote -> Score BasicNote) | |
intervalAnnotations = foldr1 (.) . zipWith notate (map spanify [0..]) | |
where | |
spanify :: Duration -> Span | |
spanify t = (origin .+^ t) >-> 1 | |
notate :: Span -> Interval -> (Score BasicNote -> Score BasicNote) | |
notate s n = annotateSpan s (" " ++ showIntervalName n) | |
showIntervalName = filter (/= '_') . show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment