diff options
author | Andrew Cady <d@jerkface.net> | 2014-01-15 09:53:34 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2014-01-15 09:53:34 -0500 |
commit | 6c933a010ff29b40722ca176e3ac5e8509bb616d (patch) | |
tree | 6693d02e223840c348da2702083de211f6027214 /midi-dump.hs | |
parent | e19c35c8a7125b53688d056bfd5cf8a276590228 (diff) |
use Haskore.Basic.Pitch to pretty-print note names
Diffstat (limited to 'midi-dump.hs')
-rw-r--r-- | midi-dump.hs | 8 |
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 | ||
21 | import qualified Data.Set as Set | 21 | import qualified Data.Set as Set |
22 | import Data.List (group, sort) | 22 | import Data.List (group, sort) |
23 | import Haskore.Basic.Pitch | ||
23 | 24 | ||
24 | joinWords [] = "" | 25 | joinWords [] = "" |
25 | joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls | 26 | joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls |
@@ -27,7 +28,11 @@ joinWords ls = foldr1 (\a b -> a ++ " " ++ b) ls | |||
27 | printWords [] = return () -- print nothing if no words (not an empty line) | 28 | printWords [] = return () -- print nothing if no words (not an empty line) |
28 | printWords ls = putStrLn $ joinWords ls | 29 | printWords ls = putStrLn $ joinWords ls |
29 | 30 | ||
30 | pitchWords set = map (show . Event.unPitch) $ Set.toList set | 31 | showPitch x = |
32 | let (octave, pitch) = Haskore.Basic.Pitch.fromInt $ fromIntegral x | ||
33 | in Haskore.Basic.Pitch.classFormat pitch (show octave) | ||
34 | |||
35 | pitchWords set = map (showPitch . Event.unPitch) $ Set.toList set | ||
31 | 36 | ||
32 | prettyNote :: Event.Note -> String | 37 | prettyNote :: Event.Note -> String |
33 | prettyNote (Event.Note noteChannel noteNote noteVelocity noteOffVelocity noteDuration) = | 38 | prettyNote (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 |