module Sound.ALSA.Sequencer.Sequencer where
import qualified Sound.ALSA.Sequencer.Marshal.Sequencer as Seq
import qualified Sound.ALSA.Exception as Exc
import qualified Foreign.C.Types as C
import Foreign.C.Types (CSize, )
import Foreign.C.String (CString, withCAString, peekCString, )
import Foreign.Ptr (Ptr, )
import Foreign.Marshal.Alloc (alloca, )
import Foreign.Storable (peek, )
import Data.Word (Word, )
import Control.Exception (bracket, )
open
:: Seq.OpenMode mode
=> String
-> Seq.BlockMode
-> IO (Seq.T mode)
open t bm = withOpenMode $ \om -> alloca $ \p -> withCAString t $ \s ->
do Exc.checkResult_ "open" =<< snd_seq_open p s (Seq.expOpenMode om) (Seq.expBlockMode bm)
fmap Seq.Cons $ peek p
openDefault
:: Seq.OpenMode mode
=> Seq.BlockMode
-> IO (Seq.T mode)
openDefault = open defaultName
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_open"
snd_seq_open :: Ptr (Ptr Seq.Core) -> CString -> C.CInt -> C.CInt -> IO C.CInt
withOpenMode :: (mode -> IO (Seq.T mode)) -> IO (Seq.T mode)
withOpenMode f = f undefined
close
:: Seq.T mode
-> IO ()
close (Seq.Cons h) = Exc.checkResult_ "close" =<< snd_seq_close h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_close"
snd_seq_close :: Ptr Seq.Core -> IO C.CInt
with
:: Seq.OpenMode mode
=> String
-> Seq.BlockMode
-> (Seq.T mode -> IO a)
-> IO a
with t bm =
bracket (open t bm) close
withDefault
:: Seq.OpenMode mode
=> Seq.BlockMode
-> (Seq.T mode -> IO a)
-> IO a
withDefault = with defaultName
defaultName :: String
defaultName = "default"
getName
:: Seq.T mode
-> IO String
getName (Seq.Cons h) = peekCString =<< snd_seq_name h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_name"
snd_seq_name :: Ptr Seq.Core -> IO CString
setBlocking
:: Seq.T mode
-> Seq.BlockMode
-> IO ()
setBlocking (Seq.Cons h) m = Exc.checkResult_ "set_blocking" =<< snd_seq_nonblock h(Seq.expBlockMode m)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_nonblock"
snd_seq_nonblock :: Ptr Seq.Core -> C.CInt -> IO C.CInt
getOutputBufferSize
:: Seq.T mode
-> IO Word
getOutputBufferSize (Seq.Cons h) =
fromIntegral `fmap` snd_seq_get_output_buffer_size h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_get_output_buffer_size"
snd_seq_get_output_buffer_size :: Ptr Seq.Core -> IO CSize
setOutputBufferSize
:: Seq.T mode
-> Word
-> IO ()
setOutputBufferSize (Seq.Cons h) x =
Exc.checkResult_ "set_output_buffer_size" =<< snd_seq_set_output_buffer_size h (fromIntegral x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_output_buffer_size"
snd_seq_set_output_buffer_size :: Ptr Seq.Core -> CSize -> IO C.CInt
getInputBufferSize
:: Seq.T mode
-> IO Word
getInputBufferSize (Seq.Cons h) =
fromIntegral `fmap` snd_seq_get_input_buffer_size h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_get_input_buffer_size"
snd_seq_get_input_buffer_size :: Ptr Seq.Core -> IO CSize
setInputBufferSize
:: Seq.T mode
-> Word
-> IO ()
setInputBufferSize (Seq.Cons h) x =
Exc.checkResult_ "set_input_buffer_size" =<< snd_seq_set_input_buffer_size h (fromIntegral x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_input_buffer_size"
snd_seq_set_input_buffer_size :: Ptr Seq.Core -> CSize -> IO C.CInt
setPoolOutput
:: Seq.T mode
-> Word
-> IO ()
setPoolOutput (Seq.Cons h) x =
Exc.checkResult_ "set_pool_output" =<< snd_seq_set_client_pool_output h (fromIntegral x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_client_pool_output"
snd_seq_set_client_pool_output :: Ptr Seq.Core -> CSize -> IO C.CInt
setPoolOutputRoom
:: Seq.T mode
-> Word
-> IO ()
setPoolOutputRoom (Seq.Cons h) x =
Exc.checkResult_ "set_pool_output_room" =<< snd_seq_set_client_pool_output_room h (fromIntegral x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_client_pool_output_room"
snd_seq_set_client_pool_output_room :: Ptr Seq.Core -> CSize -> IO C.CInt
resetPoolOutput
:: Seq.T mode
-> IO ()
resetPoolOutput (Seq.Cons h) =
Exc.checkResult_ "reset_pool_output" =<< snd_seq_reset_pool_output h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_reset_pool_output"
snd_seq_reset_pool_output :: Ptr Seq.Core -> IO C.CInt
setPoolInput
:: Seq.T mode
-> Word
-> IO ()
setPoolInput (Seq.Cons h) x =
Exc.checkResult_ "set_pool_input" =<< snd_seq_set_client_pool_input h (fromIntegral x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_client_pool_input"
snd_seq_set_client_pool_input :: Ptr Seq.Core -> CSize -> IO C.CInt
resetPoolInput
:: Seq.T mode
-> IO ()
resetPoolInput (Seq.Cons h) =
Exc.checkResult_ "reset_pool_input" =<< snd_seq_reset_pool_input h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_reset_pool_input"
snd_seq_reset_pool_input :: Ptr Seq.Core -> IO C.CInt