From 67ecbcfc95a8d2c214fac546fc7d2e83d4c4fc10 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 15 May 2018 21:24:01 +0200 Subject: Don't update level when unneccessary --- package.yaml | 2 +- trivmix.cabal | 2 +- trivmix.nix | 2 +- trivmix/Trivmix.hs | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.yaml b/package.yaml index 123fe83..44132e5 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: trivmix -version: 4.0.0 +version: 4.0.1 license: PublicDomain license-file: LICENSE author: Gregor Kleen diff --git a/trivmix.cabal b/trivmix.cabal index 962edd6..44b9ea0 100644 --- a/trivmix.cabal +++ b/trivmix.cabal @@ -1,5 +1,5 @@ name: trivmix -version: 4.0.0 +version: 4.0.1 category: Sound author: Gregor Kleen license: PublicDomain diff --git a/trivmix.nix b/trivmix.nix index bcc7037..da38e26 100644 --- a/trivmix.nix +++ b/trivmix.nix @@ -5,7 +5,7 @@ }: mkDerivation { pname = "trivmix"; - version = "4.0.0"; + version = "4.0.1"; src = ./.; isLibrary = true; isExecutable = true; diff --git a/trivmix/Trivmix.hs b/trivmix/Trivmix.hs index 5cddf6f..7c18965 100644 --- a/trivmix/Trivmix.hs +++ b/trivmix/Trivmix.hs @@ -194,7 +194,9 @@ trivmix Options{..} = do mulBalance (bToScientific -> b) x = either error id $ asScientific (*) (Lin . either error id $ refine b) x newLevel <- mulBalance <$> readMVar balance <*> readMVar level currentLevel <- (\(CFloat f) -> Lin . either error id . refine $ realToFrac f) <$> readMVar level' - mapM_ (\x -> (swapMVar level' $! toRealFloat . unrefine . toLin $ linInt' x currentLevel newLevel) >> threadDelay delay) (takeWhile (<= 1) $ iterate (+ recip frames) 0) + case compare currentLevel newLevel of + EQ -> threadDelay . round $ interval * 1e6 + _ -> mapM_ (\x -> (swapMVar level' $! toRealFloat . unrefine . toLin $ linInt' x currentLevel newLevel) >> threadDelay delay) (takeWhile (<= 1) $ iterate (+ recip frames) 0) notifyReady forever $ threadDelay (round $ watchdogInterval * 1e6) >> notifyWatchdog -- cgit v1.2.3