diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-07 20:48:12 +0200 | 
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-07 20:48:12 +0200 | 
| commit | 5e46af12608b35b73b7ac1f83e59585671d19e48 (patch) | |
| tree | 5e220ed1866fd516aeefe991be31d80d0c1a81e3 /src | |
| parent | 29f5a0340a3220b6f5ccb34c7f430df9e5ce4692 (diff) | |
| download | trivmix-5e46af12608b35b73b7ac1f83e59585671d19e48.tar trivmix-5e46af12608b35b73b7ac1f83e59585671d19e48.tar.gz trivmix-5e46af12608b35b73b7ac1f83e59585671d19e48.tar.bz2 trivmix-5e46af12608b35b73b7ac1f83e59585671d19e48.tar.xz trivmix-5e46af12608b35b73b7ac1f83e59585671d19e48.zip  | |
Option for clientname
Diffstat (limited to 'src')
| -rw-r--r-- | src/Trivmix.hs | 11 | 
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs index 019ee32..f7ae1eb 100644 --- a/src/Trivmix.hs +++ b/src/Trivmix.hs  | |||
| @@ -27,6 +27,7 @@ import System.INotify | |||
| 27 | data Options = Options | 27 | data Options = Options | 
| 28 | { input :: String | 28 | { input :: String | 
| 29 | , output :: String | 29 | , output :: String | 
| 30 | , client :: String | ||
| 30 | , initialLevel :: Float | 31 | , initialLevel :: Float | 
| 31 | , stateDir :: FilePath | 32 | , stateDir :: FilePath | 
| 32 | } | 33 | } | 
| @@ -34,10 +35,13 @@ data Options = Options | |||
| 34 | optionParser :: Parser Options | 35 | optionParser :: Parser Options | 
| 35 | optionParser = Options <$> | 36 | optionParser = Options <$> | 
| 36 | strOption ( long "input" | 37 | strOption ( long "input" | 
| 37 | <> metavar "JACK" | 38 | <> metavar "STRING" | 
| 38 | ) | 39 | ) | 
| 39 | <*> strOption ( long "output" | 40 | <*> strOption ( long "output" | 
| 40 | <> metavar "JACK" | 41 | <> metavar "STRING" | 
| 42 | ) | ||
| 43 | <*> strOption ( long "client" | ||
| 44 | <> metavar "STRING" | ||
| 41 | ) | 45 | ) | 
| 42 | <*> (fromMaybe 0 <$> optional (option auto ( long "level" | 46 | <*> (fromMaybe 0 <$> optional (option auto ( long "level" | 
| 43 | <> metavar "FLOAT" | 47 | <> metavar "FLOAT" | 
| @@ -59,14 +63,13 @@ main = execParser opts >>= trivmix | |||
| 59 | 63 | ||
| 60 | trivmix :: Options -> IO () | 64 | trivmix :: Options -> IO () | 
| 61 | trivmix Options{..} = do | 65 | trivmix Options{..} = do | 
| 62 | name <- getProgName | ||
| 63 | createDirectoryIfMissing True stateDir | 66 | createDirectoryIfMissing True stateDir | 
| 64 | level <- newMVar initialLevel | 67 | level <- newMVar initialLevel | 
| 65 | let levelFile = stateDir </> "level" | 68 | let levelFile = stateDir </> "level" | 
| 66 | onLevelFile levelFile initialLevel $ withINotify $ \n -> do | 69 | onLevelFile levelFile initialLevel $ withINotify $ \n -> do | 
| 67 | addWatch n [Modify] levelFile (const $ handleLevel level levelFile) | 70 | addWatch n [Modify] levelFile (const $ handleLevel level levelFile) | 
| 68 | Jack.handleExceptions $ | 71 | Jack.handleExceptions $ | 
| 69 | Jack.withClientDefault name $ \client -> | 72 | Jack.withClientDefault client $ \client -> | 
| 70 | Jack.withPort client input $ \input' -> | 73 | Jack.withPort client input $ \input' -> | 
| 71 | Jack.withPort client output $ \output' -> | 74 | Jack.withPort client output $ \output' -> | 
| 72 | Audio.withProcessMono client input' (mix level) output' $ | 75 | Audio.withProcessMono client input' (mix level) output' $ | 
