diff options
| -rw-r--r-- | trivmix.cabal | 2 | ||||
| -rw-r--r-- | trivmix.nix | 2 | ||||
| -rw-r--r-- | trivmix/Trivmix.hs | 17 | 
3 files changed, 16 insertions, 5 deletions
diff --git a/trivmix.cabal b/trivmix.cabal index 0149fb5..41ba03f 100644 --- a/trivmix.cabal +++ b/trivmix.cabal  | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 
| 3 | 3 | ||
| 4 | name: trivmix | 4 | name: trivmix | 
| 5 | version: 3.1.4 | 5 | version: 3.2.0 | 
| 6 | -- synopsis: | 6 | -- synopsis: | 
| 7 | -- description: | 7 | -- description: | 
| 8 | license: PublicDomain | 8 | license: PublicDomain | 
diff --git a/trivmix.nix b/trivmix.nix index 34b430a..8d0ea14 100644 --- a/trivmix.nix +++ b/trivmix.nix  | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | }: | 5 | }: | 
| 6 | mkDerivation { | 6 | mkDerivation { | 
| 7 | pname = "trivmix"; | 7 | pname = "trivmix"; | 
| 8 | version = "3.1.4"; | 8 | version = "3.2.0"; | 
| 9 | src = ./.; | 9 | src = ./.; | 
| 10 | isLibrary = true; | 10 | isLibrary = true; | 
| 11 | isExecutable = true; | 11 | isExecutable = true; | 
diff --git a/trivmix/Trivmix.hs b/trivmix/Trivmix.hs index 0758921..91dd440 100644 --- a/trivmix/Trivmix.hs +++ b/trivmix/Trivmix.hs  | |||
| @@ -53,6 +53,7 @@ data Options = Options | |||
| 53 | , client :: String | 53 | , client :: String | 
| 54 | , initialLevel :: Level | 54 | , initialLevel :: Level | 
| 55 | , initialBalance :: Balance | 55 | , initialBalance :: Balance | 
| 56 | , fps, interval :: Rational | ||
| 56 | , run :: [FilePath] | 57 | , run :: [FilePath] | 
| 57 | , balanceFiles :: [FilePath] | 58 | , balanceFiles :: [FilePath] | 
| 58 | , levelFiles :: [FilePath] | 59 | , levelFiles :: [FilePath] | 
| @@ -88,6 +89,18 @@ optionParser = Options | |||
| 88 | <> value def | 89 | <> value def | 
| 89 | <> showDefault | 90 | <> showDefault | 
| 90 | ) | 91 | ) | 
| 92 | <*> option auto ( long "fps" | ||
| 93 | <> metavar "NUMBER" | ||
| 94 | <> help "Update level ‘NUMBER’ times per second" | ||
| 95 | <> value 200 | ||
| 96 | <> showDefault | ||
| 97 | ) | ||
| 98 | <*> option auto ( long "interval" | ||
| 99 | <> metavar "NUMBER" | ||
| 100 | <> help "Smooth level transitions over ‘NUMBER’ seconds" | ||
| 101 | <> value 0.2 | ||
| 102 | <> showDefault | ||
| 103 | ) | ||
| 91 | <*> many ( strOption ( long "run" | 104 | <*> many ( strOption ( long "run" | 
| 92 | <> metavar "FILE" | 105 | <> metavar "FILE" | 
| 93 | <> help [str|Execute a file once setup of jacks is done (use this to autoconnect) | 106 | <> help [str|Execute a file once setup of jacks is done (use this to autoconnect) | 
| @@ -168,8 +181,6 @@ trivmix Options{..} = do | |||
| 168 | notifyReady | 181 | notifyReady | 
| 169 | forever $ do -- Smooth out discontinuity | 182 | forever $ do -- Smooth out discontinuity | 
| 170 | let | 183 | let | 
| 171 | fps = 200 | ||
| 172 | interval = 0.2 | ||
| 173 | frames = interval * fps | 184 | frames = interval * fps | 
| 174 | delay = round $ recip fps * 1e6 | 185 | delay = round $ recip fps * 1e6 | 
| 175 | linInt x a b = a * (1 - x) + b * x | 186 | linInt x a b = a * (1 - x) + b * x | 
| @@ -177,7 +188,7 @@ trivmix Options{..} = do | |||
| 177 | mulBalance (bToFloat -> b) x = either error id $ asFloat (*) (Lin . either error id $ refine b) x | 188 | mulBalance (bToFloat -> b) x = either error id $ asFloat (*) (Lin . either error id $ refine b) x | 
| 178 | newLevel <- mulBalance <$> readMVar balance <*> readMVar level | 189 | newLevel <- mulBalance <$> readMVar balance <*> readMVar level | 
| 179 | currentLevel <- readMVar level' | 190 | currentLevel <- readMVar level' | 
| 180 | mapM_ (\x -> swapMVar level' (linInt' x currentLevel newLevel) >> threadDelay delay) ([0,recip frames..1] :: [Float]) | 191 | mapM_ (\(fromRational -> x) -> swapMVar level' (linInt' x currentLevel newLevel) >> threadDelay delay) [0,recip frames..1] | 
| 181 | 192 | ||
| 182 | mix :: MVar Level -> CFloat -> IO CFloat | 193 | mix :: MVar Level -> CFloat -> IO CFloat | 
| 183 | mix level input = do | 194 | mix level input = do | 
