module Music.Theory.Pitch.Spelling where
import Music.Theory.Pitch.Note (Note_T(..),Alteration_T(..),Spelling)
type Spelling_M i = i -> Maybe (Note_T, Alteration_T)
pc_spell_natural_m :: Integral i => Spelling_M i
pc_spell_natural_m pc =
case pc of
0 -> Just (C,Natural)
2 -> Just (D,Natural)
4 -> Just (E,Natural)
5 -> Just (F,Natural)
7 -> Just (G,Natural)
9 -> Just (A,Natural)
11 -> Just (B,Natural)
_ -> Nothing
pc_spell_natural :: Integral i => Spelling i
pc_spell_natural pc =
case pc_spell_natural_m pc of
Just p -> p
_ -> error "pc_spell_natural"
pc_spell_ks :: Integral i => Spelling i
pc_spell_ks pc =
case pc of
1 -> (C,Sharp)
3 -> (E,Flat)
6 -> (F,Sharp)
8 -> (A,Flat)
10 -> (B,Flat)
_ -> pc_spell_natural pc
pc_spell_sharp :: Integral i => Spelling i
pc_spell_sharp pc =
case pc of
1 -> (C,Sharp)
3 -> (D,Sharp)
6 -> (F,Sharp)
8 -> (G,Sharp)
10 -> (A,Sharp)
_ -> pc_spell_natural pc
pc_spell_flat :: Integral i => Spelling i
pc_spell_flat pc =
case pc of
1 -> (D,Flat)
3 -> (E,Flat)
6 -> (G,Flat)
8 -> (A,Flat)
10 -> (B,Flat)
_ -> pc_spell_natural pc