summaryrefslogtreecommitdiff
path: root/midi-dump.hs
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2014-01-15 09:53:34 -0500
committerAndrew Cady <d@jerkface.net>2014-01-15 09:53:34 -0500
commit6c933a010ff29b40722ca176e3ac5e8509bb616d (patch)
tree6693d02e223840c348da2702083de211f6027214 /midi-dump.hs
parente19c35c8a7125b53688d056bfd5cf8a276590228 (diff)
use Haskore.Basic.Pitch to pretty-print note names
Diffstat (limited to 'midi-dump.hs')
-rw-r--r--midi-dump.hs8
1 files changed, 7 insertions, 1 deletions
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)
20 20
21import qualified Data.Set as Set 21import qualified Data.Set as Set
22import Data.List (group, sort) 22import Data.List (group, sort)
23import Haskore.Basic.Pitch
23 24
24joinWords [] = "" 25joinWords [] = ""
25joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls 26joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls
@@ -27,7 +28,11 @@ joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls
27printWords [] = return () -- print nothing if no words (not an empty line) 28printWords [] = return () -- print nothing if no words (not an empty line)
28printWords ls = putStrLn $ joinWords ls 29printWords ls = putStrLn $ joinWords ls
29 30
30pitchWords set = map (show . Event.unPitch) $ Set.toList set 31showPitch x =
32 let (octave, pitch) = Haskore.Basic.Pitch.fromInt $ fromIntegral x
33 in Haskore.Basic.Pitch.classFormat pitch (show octave)
34
35pitchWords set = map (showPitch . Event.unPitch) $ Set.toList set
31 36
32prettyNote :: Event.Note -> String 37prettyNote :: Event.Note -> String
33prettyNote (Event.Note noteChannel noteNote noteVelocity noteOffVelocity noteDuration) = 38prettyNote (Event.Note noteChannel noteNote noteVelocity noteOffVelocity noteDuration) =
@@ -131,6 +136,7 @@ main = (do
131 _ <- Event.drainOutput h 136 _ <- Event.drainOutput h
132 go down 137 go down
133 138
139 putStrLn "Rock on!"
134 go Set.empty) 140 go Set.empty)
135 `AlsaExc.catch` \e -> 141 `AlsaExc.catch` \e ->
136 putStrLn $ "alsa_exception: " ++ AlsaExc.show e 142 putStrLn $ "alsa_exception: " ++ AlsaExc.show e