summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-12-03 07:20:30 -0500
committerAndrew Cady <d@jerkface.net>2015-12-03 07:20:30 -0500
commit3c4d35d9f88ae2f1139d0f402c05132bf7e3ec81 (patch)
tree5e84be05c37f6689e1d880a9d88f28ef7557401e
parent9d8e1b9b82c1a905a0014fd5b9c5d08f7ce347f0 (diff)
record tick time in input history
-rw-r--r--midi-dump.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/midi-dump.hs b/midi-dump.hs
index b345531..b3698ae 100644
--- a/midi-dump.hs
+++ b/midi-dump.hs
@@ -13,9 +13,12 @@ main = main' `AlsaExc.catch` handler
13 where 13 where
14 handler e = putStrLn $ "alsa_exception: " ++ AlsaExc.show e 14 handler e = putStrLn $ "alsa_exception: " ++ AlsaExc.show e
15 15
16data EVENT = EVENT TimeSpec Event.T
17 deriving Show
18
16data LoopState = LoopState { 19data LoopState = LoopState {
17 keysDown :: MidiPitchSet, 20 keysDown :: MidiPitchSet,
18 inputHistory :: [Maybe Event.T], 21 inputHistory :: [Maybe EVENT],
19 lastTick :: TimeSpec 22 lastTick :: TimeSpec
20} 23}
21 24
@@ -42,7 +45,7 @@ loop = do
42 else do 45 else do
43 now <- liftIO $ getTime Monotonic 46 now <- liftIO $ getTime Monotonic
44 let delta = now - startTime 47 let delta = now - startTime
45 let newEvents = map Just events 48 let newEvents = map (Just . (EVENT now)) events
46 49
47 liftIO $ printChordLn newKeys 50 liftIO $ printChordLn newKeys
48 modify $ \s -> s { keysDown = newKeys, inputHistory = newEvents ++ inputHistory s } 51 modify $ \s -> s { keysDown = newKeys, inputHistory = newEvents ++ inputHistory s }