import Sound.Alsa
(SoundFmt(SoundFmt), copySound, sampleFreq,
fileSoundSource, alsaSoundSink, )
import System.Environment (getArgs, )
import System.Exit (exitFailure, )
import System.IO (hPutStrLn, stderr, )
import Data.Int (Int16, )
bufSize :: Int
bufSize = 8192
soundFormat :: SoundFmt Int16
soundFormat = SoundFmt { sampleFreq = 8000 }
main :: IO ()
main = do args <- getArgs
case args of
[file] -> play file
_ -> do hPutStrLn stderr "Usage: play <file.pcm>"
exitFailure
play :: FilePath -> IO ()
play file =
do let source = fileSoundSource file soundFormat
sink = alsaSoundSink "plughw:0,0" soundFormat
copySound source sink bufSize