summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--axis-of-eval.cabal2
-rw-r--r--midi-dump.hs10
2 files changed, 8 insertions, 4 deletions
diff --git a/axis-of-eval.cabal b/axis-of-eval.cabal
index d1aee15..f09386a 100644
--- a/axis-of-eval.cabal
+++ b/axis-of-eval.cabal
@@ -40,4 +40,4 @@ executable midi-dump
40 transformers, semigroups, HCodecs, threads 40 transformers, semigroups, HCodecs, threads
41 main-is: midi-dump.hs 41 main-is: midi-dump.hs
42 other-modules: AlsaSeq, Midi, RealTimeQueue 42 other-modules: AlsaSeq, Midi, RealTimeQueue
43 ghc-options: -threaded -W -Wall -O2 43 ghc-options: -threaded -W -Wall -O2 -rtsopts
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