diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-04-17 20:41:09 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-04-17 20:41:09 +0200 |
| commit | e9c853ae07e1ae922f7e70fe858ce0a6e5782343 (patch) | |
| tree | baf5599b28c9c9e409ca044b3c7b761543341272 | |
| parent | 3c0776f07f39f35597f85a176924dd84c265c0a2 (diff) | |
| parent | 4f9cf618c825a4a1833feab423a99c5c751a923f (diff) | |
| download | trivmix-e9c853ae07e1ae922f7e70fe858ce0a6e5782343.tar trivmix-e9c853ae07e1ae922f7e70fe858ce0a6e5782343.tar.gz trivmix-e9c853ae07e1ae922f7e70fe858ce0a6e5782343.tar.bz2 trivmix-e9c853ae07e1ae922f7e70fe858ce0a6e5782343.tar.xz trivmix-e9c853ae07e1ae922f7e70fe858ce0a6e5782343.zip | |
Merge commit '4f9cf61'
| -rw-r--r-- | src/Trivmix/Types.hs | 1 | ||||
| -rw-r--r-- | trivmix/Trivmix.hs | 13 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/Trivmix/Types.hs b/src/Trivmix/Types.hs index 874eb42..a6a41b9 100644 --- a/src/Trivmix/Types.hs +++ b/src/Trivmix/Types.hs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | module Trivmix.Types | 3 | module Trivmix.Types |
| 4 | ( Level | 4 | ( Level |
| 5 | , toFloat | 5 | , toFloat |
| 6 | , asFloat | ||
| 6 | , Adjustment(..) | 7 | , Adjustment(..) |
| 7 | , doAdjustment | 8 | , doAdjustment |
| 8 | , module Data.Default | 9 | , module Data.Default |
diff --git a/trivmix/Trivmix.hs b/trivmix/Trivmix.hs index fe62619..2cd1252 100644 --- a/trivmix/Trivmix.hs +++ b/trivmix/Trivmix.hs | |||
| @@ -113,6 +113,17 @@ main = execParser opts >>= trivmix | |||
| 113 | trivmix :: Options -> IO () | 113 | trivmix :: Options -> IO () |
| 114 | trivmix Options{..} = do | 114 | trivmix Options{..} = do |
| 115 | level <- newMVar initialLevel | 115 | level <- newMVar initialLevel |
| 116 | level' <- newMVar initialLevel | ||
| 117 | forkIO $ forever $ do -- Smooth out discontinuity | ||
| 118 | let | ||
| 119 | fps = 200 | ||
| 120 | interval = 0.2 | ||
| 121 | frames = interval * fps | ||
| 122 | delay = round $ recip fps * 10e6 | ||
| 123 | linInt x a b = a * (1 - x) + b * x | ||
| 124 | newLevel <- readMVar level | ||
| 125 | currentLevel <- readMVar level' | ||
| 126 | mapM_ (\x -> swapMVar level' (asFloat (linInt x) currentLevel newLevel) >> threadDelay delay) ([0..frames] :: [Float]) | ||
| 116 | let withFiles = foldl (.) id $ map (\f -> onStateFile f (show initialLevel ++ "\n")) levelFiles | 127 | let withFiles = foldl (.) id $ map (\f -> onStateFile f (show initialLevel ++ "\n")) levelFiles |
| 117 | withFiles $ withINotify $ \inotify -> do | 128 | withFiles $ withINotify $ \inotify -> do |
| 118 | handleFiles inotify level levelFiles | 129 | handleFiles inotify level levelFiles |
| @@ -126,7 +137,7 @@ trivmix Options{..} = do | |||
| 126 | Just run' -> do | 137 | Just run' -> do |
| 127 | (_, _, _, ph) <- createProcess $ (proc run' [client ++ ":" ++ input, client ++ ":" ++ output]) { delegate_ctlc = True } | 138 | (_, _, _, ph) <- createProcess $ (proc run' [client ++ ":" ++ input, client ++ ":" ++ output]) { delegate_ctlc = True } |
| 128 | return () | 139 | return () |
| 129 | Audio.withProcessMono client' input' (mix level) output' $ | 140 | Audio.withProcessMono client' input' (mix level') output' $ |
| 130 | Jack.withActivation client' $ Trans.lift Jack.waitForBreak | 141 | Jack.withActivation client' $ Trans.lift Jack.waitForBreak |
| 131 | 142 | ||
| 132 | mix :: MVar Level -> CFloat -> IO CFloat | 143 | mix :: MVar Level -> CFloat -> IO CFloat |
