feat: implement toPitch

This commit is contained in:
wi11-holdsworth 2025-09-24 14:53:50 +10:00
parent 9419d0d25b
commit 00e2dae6c1

View file

@ -33,7 +33,29 @@ instance Show Pitch where
show (Pitch note octave) = show note ++ show octave show (Pitch note octave) = show note ++ show octave
toPitch :: String -> Maybe Pitch toPitch :: String -> Maybe Pitch
toPitch _ = Just (Pitch 'A' 1) toPitch [note, octave] = Pitch <$> charToNote note <*> charToOctave octave
where
charToNote :: Char -> Maybe Note
charToNote c =
lookup
c
[ ('A', A),
('B', B),
('C', C),
('D', D),
('E', E),
('F', F),
('G', G)
]
charToOctave :: Char -> Maybe Octave
charToOctave c =
lookup
c
[ ('1', One),
('2', Two),
('3', Three)
]
toPitch _ = Nothing
feedback :: [Pitch] -> [Pitch] -> (Int, Int, Int) feedback :: [Pitch] -> [Pitch] -> (Int, Int, Int)
feedback _ _ = (0, 0, 0) feedback _ _ = (0, 0, 0)