module Music.Theory.Pitch.Spelling.Table where
import Data.Maybe
import Music.Theory.Pitch
import Music.Theory.Pitch.Note
type Spelling_Table i = [(i,(Note_T,Alteration_T))]
pc_spell_natural_tbl :: Integral i => Spelling_Table i
pc_spell_natural_tbl =
[(0,(C,Natural))
,(2,(D,Natural))
,(4,(E,Natural))
,(5,(F,Natural))
,(7,(G,Natural))
,(9,(A,Natural))
,(11,(B,Natural))]
pc_spell_sharp_tbl :: Integral i => Spelling_Table i
pc_spell_sharp_tbl =
[(1,(C,Sharp))
,(3,(D,Sharp))
,(6,(F,Sharp))
,(8,(G,Sharp))
,(10,(A,Sharp))]
pc_spell_flat_tbl :: Integral i => Spelling_Table i
pc_spell_flat_tbl =
[(1,(D,Flat))
,(3,(E,Flat))
,(6,(G,Flat))
,(8,(A,Flat))
,(10,(B,Flat))]
pc_spell_ks_tbl :: Integral i => Spelling_Table i
pc_spell_ks_tbl =
[(1,(C,Sharp))
,(3,(E,Flat))
,(6,(F,Sharp))
,(8,(A,Flat))
,(10,(B,Flat))]
pc_spell_tbl :: Integral i => Spelling_Table i -> Spelling i
pc_spell_tbl tbl = fromMaybe (error "pc_spell_tbl") . flip lookup tbl
pc_spell_tbl_ks :: Integral i => Spelling_Table i -> Spelling i
pc_spell_tbl_ks tbl = pc_spell_tbl (tbl ++ pc_spell_natural_tbl ++ pc_spell_ks_tbl)
pc_spell_natural_m :: Integral i => Spelling_M i
pc_spell_natural_m = flip lookup pc_spell_natural_tbl
pc_spell_natural :: Integral i => Spelling i
pc_spell_natural = pc_spell_tbl pc_spell_natural_tbl
pc_spell_ks :: Integral i => Spelling i
pc_spell_ks = pc_spell_tbl_ks []
pc_spell_sharp :: Integral i => Spelling i
pc_spell_sharp = pc_spell_tbl (pc_spell_sharp_tbl ++ pc_spell_natural_tbl)
pc_spell_flat :: Integral i => Spelling i
pc_spell_flat = pc_spell_tbl (pc_spell_flat_tbl ++ pc_spell_natural_tbl)
octpc_to_pitch_ks :: Integral i => Octave_PitchClass i -> Pitch
octpc_to_pitch_ks = octpc_to_pitch pc_spell_ks
midi_to_pitch_ks :: Integral i => i -> Pitch
midi_to_pitch_ks = midi_to_pitch pc_spell_ks
fmidi_to_pitch_ks :: (Show n,RealFrac n) => n -> Pitch
fmidi_to_pitch_ks = fmidi_to_pitch_err pc_spell_ks
midi_detune_to_pitch_ks :: Real c => Midi_Detune' c -> Pitch
midi_detune_to_pitch_ks = midi_detune_to_pitch pc_spell_ks