diff options
Diffstat (limited to 'midi-dump.hs')
-rw-r--r-- | midi-dump.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/midi-dump.hs b/midi-dump.hs index 59a9df5..275593d 100644 --- a/midi-dump.hs +++ b/midi-dump.hs | |||
@@ -221,12 +221,16 @@ mainLoop = do | |||
221 | else delay >> mainLoop | 221 | else delay >> mainLoop |
222 | 222 | ||
223 | where | 223 | where |
224 | tickDuration = 5000 -- 5ms | 224 | tickDurationMilliseconds = 4 |
225 | |||
226 | tickDuration = TimeSpec 0 (tickDurationMilliseconds * 10^(6::Int64)) | ||
225 | delay = do | 227 | delay = do |
226 | before <- gets _lastTick | 228 | before <- gets _lastTick |
229 | liftIO performMinorGC | ||
227 | after <- getAbsTime | 230 | after <- getAbsTime |
228 | if after - before < fromIntegral (10^(6::Int) * tickDuration) then | 231 | let duration = tickDuration - (after - before) |
229 | liftIO $ threadDelay $ tickDuration - fromIntegral (nsec after - nsec before) `div` 1000 | 232 | if duration > 0 then |
233 | liftIO $ threadDelay $ fromIntegral (nsec duration) `div` 1000 | ||
230 | else | 234 | else |
231 | liftIO $ putStrLn "Uh oh! Dropped frame!" | 235 | liftIO $ putStrLn "Uh oh! Dropped frame!" |
232 | mainLoop | 236 | mainLoop |