From 6c933a010ff29b40722ca176e3ac5e8509bb616d Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Wed, 15 Jan 2014 09:53:34 -0500 Subject: use Haskore.Basic.Pitch to pretty-print note names --- midi-dump.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'midi-dump.hs') diff --git a/midi-dump.hs b/midi-dump.hs index 2c8d430..e4bce6a 100644 --- a/midi-dump.hs +++ b/midi-dump.hs @@ -20,6 +20,7 @@ import Control.Monad (when, forM_, forM) import qualified Data.Set as Set import Data.List (group, sort) +import Haskore.Basic.Pitch joinWords [] = "" joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls @@ -27,7 +28,11 @@ joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls printWords [] = return () -- print nothing if no words (not an empty line) printWords ls = putStrLn $ joinWords ls -pitchWords set = map (show . Event.unPitch) $ Set.toList set +showPitch x = + let (octave, pitch) = Haskore.Basic.Pitch.fromInt $ fromIntegral x + in Haskore.Basic.Pitch.classFormat pitch (show octave) + +pitchWords set = map (showPitch . Event.unPitch) $ Set.toList set prettyNote :: Event.Note -> String prettyNote (Event.Note noteChannel noteNote noteVelocity noteOffVelocity noteDuration) = @@ -131,6 +136,7 @@ main = (do _ <- Event.drainOutput h go down + putStrLn "Rock on!" go Set.empty) `AlsaExc.catch` \e -> putStrLn $ "alsa_exception: " ++ AlsaExc.show e -- cgit v1.2.3