diff options
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' $ |
