summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-12-04 00:21:25 -0500
committerAndrew Cady <d@jerkface.net>2015-12-04 00:21:25 -0500
commitd4427c26c730edaa07fb2258288ec133b5169744 (patch)
tree81436c921a9dab634facdcb30708f90c6d333af2
parent5ecda50f4aa1123aea0f22c3810336ea963e8e90 (diff)
renames to avoid shadowing
-rw-r--r--midi-dump.hs46
1 files changed, 23 insertions, 23 deletions
diff --git a/midi-dump.hs b/midi-dump.hs
index dd97d69..3d3f393 100644
--- a/midi-dump.hs
+++ b/midi-dump.hs
@@ -51,24 +51,24 @@ data LoopState = LoopState {
51} 51}
52 52
53data LoopEnv = LoopEnv { 53data LoopEnv = LoopEnv {
54 saver :: Chan (Int64, Int64, [EVENT]), 54 _saver :: Chan (Int64, Int64, [EVENT]),
55 sqlite :: Connection, 55 _sqlite :: Connection,
56 startTime :: TimeSpec, 56 _startTime :: TimeSpec,
57 startTimeReal :: TimeSpec, 57 _startTimeReal :: TimeSpec,
58 h :: Sound.ALSA.Sequencer.T Sound.ALSA.Sequencer.DuplexMode, 58 _h :: Sound.ALSA.Sequencer.T Sound.ALSA.Sequencer.DuplexMode,
59 public :: Sound.ALSA.Sequencer.Port.T, 59 _public :: Sound.ALSA.Sequencer.Port.T,
60 private :: Sound.ALSA.Sequencer.Port.T, 60 _private :: Sound.ALSA.Sequencer.Port.T,
61 q :: Sound.ALSA.Sequencer.Queue.T, 61 _q :: Sound.ALSA.Sequencer.Queue.T,
62 publicAddr :: Sound.ALSA.Sequencer.Address.T, 62 _publicAddr :: Sound.ALSA.Sequencer.Address.T,
63 privateAddr :: Sound.ALSA.Sequencer.Address.T, 63 _privateAddr :: Sound.ALSA.Sequencer.Address.T,
64 doSave :: Bool, 64 _doSave :: Bool,
65 lineReader :: MVar (String) 65 _lineReader :: MVar (String)
66} 66}
67 67
68getAbsTime = do 68getAbsTime = do
69 sqlite <- asks sqlite 69 sqlite <- asks _sqlite
70 startTime <- asks startTime 70 startTime <- asks _startTime
71 startTimeReal <- asks startTimeReal 71 startTimeReal <- asks _startTimeReal
72 now <- liftIO $ getTime Monotonic 72 now <- liftIO $ getTime Monotonic
73 return $ now - startTime + startTimeReal 73 return $ now - startTime + startTimeReal
74 74
@@ -94,11 +94,11 @@ main' = withAlsaInit $ \h public private q publicAddr privateAddr -> do
94 return () 94 return ()
95 95
96loop = do 96loop = do
97 startTime <- asks startTime 97 startTime <- asks _startTime
98 startTimeReal <- asks startTimeReal 98 startTimeReal <- asks _startTimeReal
99 h <- asks h 99 h <- asks _h
100 q <- asks q 100 q <- asks _q
101 publicAddr <- asks publicAddr 101 publicAddr <- asks _publicAddr
102 102
103 mapM_ (liftIO . putStrLn . ("got line: " ++)) =<< maybeReadLine 103 mapM_ (liftIO . putStrLn . ("got line: " ++)) =<< maybeReadLine
104 104
@@ -126,13 +126,13 @@ loop = do
126 modify $ \s -> s { inputHistory = Silence now:inputHistory s } 126 modify $ \s -> s { inputHistory = Silence now:inputHistory s }
127 -} 127 -}
128 128
129 doSave <- asks doSave 129 doSave <- asks _doSave
130 when doSave $ gets inputHistory >>= saveMidi >> return () 130 when doSave $ gets inputHistory >>= saveMidi >> return ()
131 modify $ \s -> s { inputHistory = [] } 131 modify $ \s -> s { inputHistory = [] }
132 132
133 loop 133 loop
134 134
135maybeReadLine = asks lineReader >>= liftIO . tryTakeMVar 135maybeReadLine = asks _lineReader >>= liftIO . tryTakeMVar
136startLineReader = do 136startLineReader = do
137 mv <- liftIO $ newEmptyMVar 137 mv <- liftIO $ newEmptyMVar
138 thread <- liftIO $ forkIO (forever $ getLine >>= putMVar mv) 138 thread <- liftIO $ forkIO (forever $ getLine >>= putMVar mv)
@@ -146,7 +146,7 @@ instance ToRow Chunk where
146 toRow (Chunk s ns b) = toRow (s, ns, b) 146 toRow (Chunk s ns b) = toRow (s, ns, b)
147 147
148saveMidi chunk = do 148saveMidi chunk = do
149 saver <- asks saver 149 saver <- asks _saver
150 (TimeSpec s ns) <- gets lastTick 150 (TimeSpec s ns) <- gets lastTick
151 liftIO $ writeChan saver (s, ns, chunk) 151 liftIO $ writeChan saver (s, ns, chunk)
152 152