summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Trivmix.hs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs
index f7ae1eb..a139a15 100644
--- a/src/Trivmix.hs
+++ b/src/Trivmix.hs
@@ -18,6 +18,7 @@ import Control.Concurrent
18import Control.Concurrent.MVar 18import Control.Concurrent.MVar
19 19
20import qualified Control.Monad.Trans.Class as Trans 20import qualified Control.Monad.Trans.Class as Trans
21import qualified Control.Monad.Exception.Synchronous as Sync
21 22
22import Control.Exception 23import Control.Exception
23import System.IO.Error 24import System.IO.Error
@@ -28,6 +29,8 @@ data Options = Options
28 { input :: String 29 { input :: String
29 , output :: String 30 , output :: String
30 , client :: String 31 , client :: String
32 , connFrom :: Maybe String
33 , connTo :: Maybe String
31 , initialLevel :: Float 34 , initialLevel :: Float
32 , stateDir :: FilePath 35 , stateDir :: FilePath
33 } 36 }
@@ -43,6 +46,12 @@ optionParser = Options <$>
43 <*> strOption ( long "client" 46 <*> strOption ( long "client"
44 <> metavar "STRING" 47 <> metavar "STRING"
45 ) 48 )
49 <*> optional (strOption ( long "input-from"
50 <> metavar "STRING"
51 ))
52 <*> optional (strOption ( long "output-to"
53 <> metavar "STRING"
54 ))
46 <*> (fromMaybe 0 <$> optional (option auto ( long "level" 55 <*> (fromMaybe 0 <$> optional (option auto ( long "level"
47 <> metavar "FLOAT" 56 <> metavar "FLOAT"
48 ) 57 )
@@ -71,10 +80,16 @@ trivmix Options{..} = do
71 Jack.handleExceptions $ 80 Jack.handleExceptions $
72 Jack.withClientDefault client $ \client -> 81 Jack.withClientDefault client $ \client ->
73 Jack.withPort client input $ \input' -> 82 Jack.withPort client input $ \input' ->
74 Jack.withPort client output $ \output' -> 83 Jack.withPort client output $ \output' -> do
75 Audio.withProcessMono client input' (mix level) output' $ 84 case connFrom of
76 Jack.withActivation client $ Trans.lift $ do 85 Nothing -> return ()
77 Jack.waitForBreak 86 Just f -> Jack.connect client input f
87 case connTo of
88 Nothing -> return ()
89 Just t -> Jack.connect client t output
90 Audio.withProcessMono client input' (mix level) output' $
91 Jack.withActivation client $ Trans.lift $ do
92 Jack.waitForBreak
78 93
79mix :: MVar Float -> CFloat -> IO CFloat 94mix :: MVar Float -> CFloat -> IO CFloat
80mix level input = do 95mix level input = do