Skip to content

Instantly share code, notes, and snippets.

@meditans
Created March 25, 2014 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meditans/9762657 to your computer and use it in GitHub Desktop.
Save meditans/9762657 to your computer and use it in GitHub Desktop.
Interval analysis of a Cantus firmus
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