diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-07 21:46:59 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-07 21:46:59 +0200 |
| commit | 495004dfe17f85d370b7f5237d5e71b367af98ca (patch) | |
| tree | e8c1f39be92106a7b4e52945703ed1313c7814e2 | |
| parent | 3316e2b9c930a0f72285d502e8aaa84819153a0d (diff) | |
| download | trivmix-495004dfe17f85d370b7f5237d5e71b367af98ca.tar trivmix-495004dfe17f85d370b7f5237d5e71b367af98ca.tar.gz trivmix-495004dfe17f85d370b7f5237d5e71b367af98ca.tar.bz2 trivmix-495004dfe17f85d370b7f5237d5e71b367af98ca.tar.xz trivmix-495004dfe17f85d370b7f5237d5e71b367af98ca.zip | |
automatic connections
| -rw-r--r-- | src/Trivmix.hs | 23 | ||||
| -rw-r--r-- | trivmix.cabal | 3 |
2 files changed, 21 insertions, 5 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 | |||
| 18 | import Control.Concurrent.MVar | 18 | import Control.Concurrent.MVar |
| 19 | 19 | ||
| 20 | import qualified Control.Monad.Trans.Class as Trans | 20 | import qualified Control.Monad.Trans.Class as Trans |
| 21 | import qualified Control.Monad.Exception.Synchronous as Sync | ||
| 21 | 22 | ||
| 22 | import Control.Exception | 23 | import Control.Exception |
| 23 | import System.IO.Error | 24 | import 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 | ||
| 79 | mix :: MVar Float -> CFloat -> IO CFloat | 94 | mix :: MVar Float -> CFloat -> IO CFloat |
| 80 | mix level input = do | 95 | mix level input = do |
diff --git a/trivmix.cabal b/trivmix.cabal index 8eee4f0..3031c98 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: 0.1.0 | 5 | version: 0.2.0 |
| 6 | -- synopsis: | 6 | -- synopsis: |
| 7 | -- description: | 7 | -- description: |
| 8 | license: PublicDomain | 8 | license: PublicDomain |
| @@ -27,6 +27,7 @@ executable trivmix | |||
| 27 | , unix >=2.7 && <3 | 27 | , unix >=2.7 && <3 |
| 28 | , hinotify >=0.3 && <1 | 28 | , hinotify >=0.3 && <1 |
| 29 | , transformers >=0.3 && <1 | 29 | , transformers >=0.3 && <1 |
| 30 | , explicit-exception >=0.1 && <1 | ||
| 30 | hs-source-dirs: src | 31 | hs-source-dirs: src |
| 31 | default-language: Haskell2010 | 32 | default-language: Haskell2010 |
| 32 | 33 | ||
