summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-12-06 03:14:05 -0500
committerAndrew Cady <d@jerkface.net>2015-12-06 03:14:05 -0500
commitb6a53650153ba5f0b6cab3679d582c0788107e9c (patch)
tree40340488996d4190ae4d54c811f620b74ebd652c
parent38b6cd686acd70b0d94271e8256cd573ecc52ced (diff)
variable rename & type alias
-rw-r--r--midi-dump.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/midi-dump.hs b/midi-dump.hs
index 07dfb1c..f332482 100644
--- a/midi-dump.hs
+++ b/midi-dump.hs
@@ -44,7 +44,7 @@ data LoopState = LoopState {
44 _playNOW :: [Event.Data], 44 _playNOW :: [Event.Data],
45 _recording :: Recording, 45 _recording :: Recording,
46 _replay :: Recording, 46 _replay :: Recording,
47 lastTick :: TimeSpec 47 _lastTick :: TimeSpec
48} 48}
49 49
50initializeState :: TimeSpec -> LoopState 50initializeState :: TimeSpec -> LoopState
@@ -183,7 +183,11 @@ processCommand "C'" = do
183-} 183-}
184processCommand str = liftIO $ putStrLn $ "Unknown command: " ++ str 184processCommand str = liftIO $ putStrLn $ "Unknown command: " ++ str
185 185
186playRecording :: Recording -> RWST LoopEnv () LoopState IO () 186type MidiControllerT m = RWST LoopEnv () LoopState m
187type MidiController = MidiControllerT IO
188
189-- playRecording :: Recording -> RWST LoopEnv () LoopState IO ()
190playRecording :: Recording -> MidiController ()
187playRecording (RecordingInProgress _ _ evts@(_:_)) = 191playRecording (RecordingInProgress _ _ evts@(_:_)) =
188 mapM_ (uncurry delayNoteEv) (zip (subtract (head delays) <$> delays) events) 192 mapM_ (uncurry delayNoteEv) (zip (subtract (head delays) <$> delays) events)
189 where (delays, events) = unzip $ fmap Event.body <$> reverse evts 193 where (delays, events) = unzip $ fmap Event.body <$> reverse evts
@@ -211,7 +215,7 @@ processMidi = do
211 let newEvents = map ((,) now) events 215 let newEvents = map ((,) now) events
212 216
213 liftIO $ printChordLn newKeys 217 liftIO $ printChordLn newKeys
214 modify $ \s -> s { keysDown = newKeys, _recording = recordEvents (_recording s) newEvents, lastTick = now } 218 modify $ \s -> s { keysDown = newKeys, _recording = recordEvents (_recording s) newEvents, _lastTick = now }
215 219
216 when (Set.null newKeys) $ do 220 when (Set.null newKeys) $ do
217 221
@@ -245,7 +249,7 @@ startLineReader = do
245saveMidi :: forall (m :: * -> *). (MonadIO m, MonadState LoopState m, MonadReader LoopEnv m) => Recording -> m () 249saveMidi :: forall (m :: * -> *). (MonadIO m, MonadState LoopState m, MonadReader LoopEnv m) => Recording -> m ()
246saveMidi recording = do 250saveMidi recording = do
247 saver <- asks _saver 251 saver <- asks _saver
248 now <- gets lastTick 252 now <- gets _lastTick
249 mapM_ (liftIO . writeChan saver) $ stopRecording recording now 253 mapM_ (liftIO . writeChan saver) $ stopRecording recording now
250 254
251startSaver :: forall (m :: * -> *). MonadIO m => Connection -> m (Chan CompleteRecording) 255startSaver :: forall (m :: * -> *). MonadIO m => Connection -> m (Chan CompleteRecording)