module Music.Theory.Pitch.Spelling.Key where
import qualified Music.Theory.Key as T
import qualified Music.Theory.Pitch as T
import qualified Music.Theory.Pitch.Note as T
import qualified Music.Theory.Pitch.Spelling.Table as T
pcset_spell_implied_key_f :: Integral i => [i] -> Maybe (T.Spelling i)
pcset_spell_implied_key_f x =
case T.implied_fifths T.Major_Mode x of
Nothing -> Nothing
Just n -> if n == 0
then Just T.pc_spell_natural
else if n < 0
then Just T.pc_spell_flat
else Just T.pc_spell_sharp
pcset_spell_implied_key :: Integral i => [i] -> Maybe [(T.Note_T, T.Alteration_T)]
pcset_spell_implied_key x =
case pcset_spell_implied_key_f x of
Just f -> Just (map f x)
Nothing -> Nothing
octpc_spell_implied_key :: [T.OctPC] -> Maybe [T.Pitch]
octpc_spell_implied_key x =
let f o (n,a) = T.Pitch n a o
in fmap (zipWith f (map fst x)) (pcset_spell_implied_key (map snd x))
midi_spell_implied_key :: [T.Midi] -> Maybe [T.Pitch]
midi_spell_implied_key = octpc_spell_implied_key . map T.midi_to_octpc