encodeTransmission :: Options -> IO ()
encodeTransmission opts = do
  input <- getContents
  case Megaparsec.parse transmission "" input of
    Left err -> hPutStrLn stderr $ Megaparsec.parseErrorPretty err
    Right x ->
      (runTransmission opts x <$> newStdGen) >>=
      (write . ByteString.Builder.toLazyByteString)
  where
    write
      | optThrottle opts = writeSamples (throttledPutStr (optSampleRate opts))
      | otherwise = writeSamples ByteString.putStr
encodeTransmission :: Options -> IO ()
encodeTransmission opts = do
  input <- getContents
  case Megaparsec.parse transmission "" input of
    Left err -> hPutStrLn stderr $ Megaparsec.parseErrorPretty err
    Right x ->
      (runTransmission opts x <$> newStdGen) >>=
      (write . ByteString.Builder.toLazyByteString)
  where
    write
      | optThrottle opts = writeSamples (throttledPutStr (optSampleRate opts))
      | otherwise = writeSamples ByteString.putStr
encodeTransmission opts = do
  input <- getContents
  case Megaparsec.parse transmission "" input of
    Left err -> hPutStrLn stderr $ Megaparsec.parseErrorPretty err
    Right x ->
      (runTransmission opts x <$> newStdGen) >>=
      (write . ByteString.Builder.toLazyByteString)
  where
    write
      | optThrottle opts = writeSamples (throttledPutStr (optSampleRate opts))
      | otherwise = writeSamples ByteString.putStr