module Sound.Alsa.Sequencer.Port
( Port
, port_system_timer
, port_system_announce
, port_unknown
, PortCap
, cap_read
, cap_write
, cap_sync_read
, cap_sync_write
, cap_duplex
, cap_subs_read
, cap_subs_write
, cap_no_export
, caps
, PortType
, type_specific
, type_midi_generic
, type_midi_gm
, type_midi_gs
, type_midi_xg
, type_midi_mt32
, type_midi_gm2
, type_synth
, type_direct_sample
, type_sample
, type_hardware
, type_software
, type_synthesizer
, type_port
, type_application
, types
, PortInfo
, create_port
, create_simple_port
, delete_port
, get_port_info
, get_any_port_info
, query_first_port
, query_next_port
, set_port_info
, port_info_copy
, port_info_clone
, port_info_get_port
, port_info_get_client
, port_info_get_addr
, port_info_get_name
, port_info_get_capability
, port_info_get_midi_channels
, port_info_get_midi_voices
, port_info_get_synth_voices
, port_info_get_port_specified
, port_info_get_timestamping
, port_info_get_timestamp_real
, port_info_get_timestamp_queue
, port_info_get_read_use
, port_info_get_write_use
, port_info_set_port
, port_info_set_client
, port_info_set_addr
, port_info_set_name
, port_info_set_capability
, port_info_set_midi_channels
, port_info_set_synth_voices
, port_info_set_midi_voices
, port_info_set_port_specified
, port_info_set_timestamping
, port_info_set_timestamp_real
, port_info_set_timestamp_queue
) where
import Foreign.C.Types(CInt,CUInt)
import Foreign.C.String(CString,withCAString)
import Foreign.Ptr(Ptr)
import Foreign.Marshal.Alloc(alloca)
import Foreign.Storable
import Sound.Alsa.Sequencer.Marshal
import Sound.Alsa.Sequencer.Area
import Sound.Alsa.Sequencer.Errors
create_simple_port :: SndSeq -> String -> PortCap -> PortType -> IO Port
create_simple_port (SndSeq h) s (PortCap c) (PortType t) =
withCAString s $ \a ->
imp_Port `fmap` (check_error =<< snd_seq_create_simple_port h a c t)
foreign import ccall "alsa/asoundlib.h snd_seq_create_simple_port"
snd_seq_create_simple_port :: Ptr SndSeq_ -> CString -> CUInt -> CUInt
-> IO CInt
create_port :: SndSeq -> PortInfo -> IO ()
create_port (SndSeq s) p =
check_error_ =<< with_port_info p (snd_seq_create_port s)
foreign import ccall "alsa/asoundlib.h snd_seq_create_port"
snd_seq_create_port :: Ptr SndSeq_ -> Ptr PortInfo_ -> IO CInt
delete_port :: SndSeq -> Port -> IO ()
delete_port (SndSeq h) (Port p) =
check_error_ =<< snd_seq_delete_port h (fromIntegral p)
foreign import ccall "alsa/asoundlib.h snd_seq_delete_port"
snd_seq_delete_port :: Ptr SndSeq_ -> CInt -> IO CInt
get_port_info :: SndSeq -> Port -> IO PortInfo
get_port_info (SndSeq h) p =
do info <- port_info_malloc
check_error =<< with_port_info info (snd_seq_get_port_info h (exp_Port p))
return info
foreign import ccall "alsa/asoundlib.h snd_seq_get_port_info"
snd_seq_get_port_info :: Ptr SndSeq_ -> CInt -> Ptr PortInfo_ -> IO CInt
get_any_port_info :: SndSeq -> Client -> Port -> IO PortInfo
get_any_port_info (SndSeq h) c p =
do info <- port_info_malloc
check_error =<< with_port_info info
(snd_seq_get_any_port_info h (exp_Client c) (exp_Port p))
return info
foreign import ccall "alsa/asoundlib.h snd_seq_get_any_port_info"
snd_seq_get_any_port_info
:: Ptr SndSeq_ -> CInt -> CInt -> Ptr PortInfo_ -> IO CInt
query_first_port :: SndSeq -> IO PortInfo
query_first_port s =
do x <- port_info_malloc
with_port_info x (`snd_seq_port_info_set_port` (1))
query_next_port s x
return x
query_next_port :: SndSeq -> PortInfo -> IO ()
query_next_port (SndSeq h) info =
check_error_ =<< with_port_info info (snd_seq_query_next_port h)
foreign import ccall "alsa/asoundlib.h snd_seq_query_next_port"
snd_seq_query_next_port :: Ptr SndSeq_ -> Ptr PortInfo_ -> IO CInt
set_port_info :: SndSeq -> Port -> PortInfo -> IO ()
set_port_info (SndSeq h) p info =
check_error_ =<< with_port_info info (snd_seq_set_port_info h (exp_Port p))
foreign import ccall "alsa/asoundlib.h snd_seq_set_port_info"
snd_seq_set_port_info :: Ptr SndSeq_ -> CInt -> Ptr PortInfo_ -> IO CInt
port_info_get_addr :: PortInfo -> IO Addr
port_info_get_addr i =
peek =<< with_port_info i snd_seq_port_info_get_addr
foreign import ccall "alsa/asoundlib.h snd_seq_port_info_get_addr"
snd_seq_port_info_get_addr :: Ptr PortInfo_ -> IO (Ptr Addr)
port_info_set_addr :: PortInfo -> Addr -> IO ()
port_info_set_addr i c =
alloca $ \p -> poke p c >> with_port_info i (`snd_seq_port_info_set_addr` p)
foreign import ccall "alsa/asoundlib.h snd_seq_port_info_set_addr"
snd_seq_port_info_set_addr :: Ptr PortInfo_ -> Ptr Addr -> IO ()