diff options
Diffstat (limited to 'trivmix/Trivmix.hs')
-rw-r--r-- | trivmix/Trivmix.hs | 13 |
1 files changed, 12 insertions, 1 deletions
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 |