module Sound.ALSA.Sequencer.Sequencer where
import qualified Sound.ALSA.Sequencer.Marshal.Port as Port
import qualified Sound.ALSA.Sequencer.Marshal.Sequencer as Seq
import qualified Sound.ALSA.Sequencer.Marshal.Address as Addr
import qualified Sound.ALSA.Exception as Exc
import Foreign.C.Types (CInt, 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
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_open"
snd_seq_open :: Ptr (Ptr Seq.Core) -> CString -> CInt -> CInt -> IO 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 CInt
with
:: Seq.OpenMode mode
=> String
-> Seq.BlockMode
-> (Seq.T mode -> IO a)
-> IO a
with t bm =
bracket (open t bm) close
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 -> CInt -> IO 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 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 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 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 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 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 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 CInt
connectFrom :: Seq.AllowInput mode => Seq.T mode -> Port.T -> Addr.T -> IO ()
connectFrom (Seq.Cons h) me a =
Exc.checkResult_ "connect_from" =<< snd_seq_connect_from h (Port.exp me) c p
where (c,p) = Addr.exp a
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_connect_from"
snd_seq_connect_from :: Ptr Seq.Core -> CInt -> CInt -> CInt -> IO CInt
connectTo :: Seq.AllowOutput mode => Seq.T mode -> Port.T -> Addr.T -> IO ()
connectTo (Seq.Cons h) me a =
Exc.checkResult_ "connect_to" =<< snd_seq_connect_to h (Port.exp me) c p
where (c,p) = Addr.exp a
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_connect_to"
snd_seq_connect_to :: Ptr Seq.Core -> CInt -> CInt -> CInt -> IO CInt
disconnectFrom :: Seq.AllowInput mode => Seq.T mode -> Port.T -> Addr.T -> IO ()
disconnectFrom (Seq.Cons h) me a =
Exc.checkResult_ "disconnect_from" =<< snd_seq_disconnect_from h (Port.exp me) c p
where (c,p) = Addr.exp a
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_disconnect_from"
snd_seq_disconnect_from :: Ptr Seq.Core -> CInt -> CInt -> CInt -> IO CInt
disconnectTo :: Seq.AllowOutput mode => Seq.T mode -> Port.T -> Addr.T -> IO ()
disconnectTo (Seq.Cons h) me a =
Exc.checkResult_ "disconnect_to" =<< snd_seq_disconnect_to h (Port.exp me) c p
where (c,p) = Addr.exp a
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_disconnect_to"
snd_seq_disconnect_to :: Ptr Seq.Core -> CInt -> CInt -> CInt -> IO CInt
parseAddress
:: Seq.T mode
-> String
-> IO Addr.T
parseAddress (Seq.Cons h) s =
alloca $ \pa ->
withCAString s $ \ps ->
do Exc.checkResult_ "parse_address" =<< snd_seq_parse_address h pa ps
peek pa
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_parse_address"
snd_seq_parse_address :: Ptr Seq.Core -> Ptr Addr.T -> CString -> IO CInt