{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Music.Utilities
( Abstract (..)
, mode
, line, chord
) where
import Music.Transformations
import Music.Types
class Abstract rep
a
inst
where
instantiate :: a -> rep -> inst
instance Abstract [Interval] Pitch [Pitch] where
instantiate p rep = [p ~> i | i <- rep]
instance Abstract [Interval] PitchClass [PitchClass] where
instantiate p rep = [p ~~> if i - P8 > P1 then i - P8 else i | i <- rep]
instance Abstract Interval PitchClass PitchClass where
instantiate p rep = p ~> rep
instance (Functor f, Abstract rep a inst) => Abstract rep (f a) (f inst) where
instantiate ma rep = (`instantiate` rep) <$> ma
mode :: Int -> AbstractChord -> AbstractChord
mode = invertN