diff options
author | Andrew Cady <d@jerkface.net> | 2015-12-06 03:14:05 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2015-12-06 03:14:05 -0500 |
commit | b6a53650153ba5f0b6cab3679d582c0788107e9c (patch) | |
tree | 40340488996d4190ae4d54c811f620b74ebd652c | |
parent | 38b6cd686acd70b0d94271e8256cd573ecc52ced (diff) |
variable rename & type alias
-rw-r--r-- | midi-dump.hs | 12 |
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 | ||
50 | initializeState :: TimeSpec -> LoopState | 50 | initializeState :: TimeSpec -> LoopState |
@@ -183,7 +183,11 @@ processCommand "C'" = do | |||
183 | -} | 183 | -} |
184 | processCommand str = liftIO $ putStrLn $ "Unknown command: " ++ str | 184 | processCommand str = liftIO $ putStrLn $ "Unknown command: " ++ str |
185 | 185 | ||
186 | playRecording :: Recording -> RWST LoopEnv () LoopState IO () | 186 | type MidiControllerT m = RWST LoopEnv () LoopState m |
187 | type MidiController = MidiControllerT IO | ||
188 | |||
189 | -- playRecording :: Recording -> RWST LoopEnv () LoopState IO () | ||
190 | playRecording :: Recording -> MidiController () | ||
187 | playRecording (RecordingInProgress _ _ evts@(_:_)) = | 191 | playRecording (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 | |||
245 | saveMidi :: forall (m :: * -> *). (MonadIO m, MonadState LoopState m, MonadReader LoopEnv m) => Recording -> m () | 249 | saveMidi :: forall (m :: * -> *). (MonadIO m, MonadState LoopState m, MonadReader LoopEnv m) => Recording -> m () |
246 | saveMidi recording = do | 250 | saveMidi 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 | ||
251 | startSaver :: forall (m :: * -> *). MonadIO m => Connection -> m (Chan CompleteRecording) | 255 | startSaver :: forall (m :: * -> *). MonadIO m => Connection -> m (Chan CompleteRecording) |