From 495004dfe17f85d370b7f5237d5e71b367af98ca Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 7 Jun 2015 21:46:59 +0200 Subject: automatic connections --- src/Trivmix.hs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/Trivmix.hs') 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 import Control.Concurrent.MVar import qualified Control.Monad.Trans.Class as Trans +import qualified Control.Monad.Exception.Synchronous as Sync import Control.Exception import System.IO.Error @@ -28,6 +29,8 @@ data Options = Options { input :: String , output :: String , client :: String + , connFrom :: Maybe String + , connTo :: Maybe String , initialLevel :: Float , stateDir :: FilePath } @@ -43,6 +46,12 @@ optionParser = Options <$> <*> strOption ( long "client" <> metavar "STRING" ) + <*> optional (strOption ( long "input-from" + <> metavar "STRING" + )) + <*> optional (strOption ( long "output-to" + <> metavar "STRING" + )) <*> (fromMaybe 0 <$> optional (option auto ( long "level" <> metavar "FLOAT" ) @@ -71,10 +80,16 @@ trivmix Options{..} = do Jack.handleExceptions $ Jack.withClientDefault client $ \client -> Jack.withPort client input $ \input' -> - Jack.withPort client output $ \output' -> - Audio.withProcessMono client input' (mix level) output' $ - Jack.withActivation client $ Trans.lift $ do - Jack.waitForBreak + Jack.withPort client output $ \output' -> do + case connFrom of + Nothing -> return () + Just f -> Jack.connect client input f + case connTo of + Nothing -> return () + Just t -> Jack.connect client t output + Audio.withProcessMono client input' (mix level) output' $ + Jack.withActivation client $ Trans.lift $ do + Jack.waitForBreak mix :: MVar Float -> CFloat -> IO CFloat mix level input = do -- cgit v1.2.3