module Sound.ALSA.Sequencer.Event
( syncOutputQueue
, input
, inputPending
, output
, outputBuffer
, outputDirect
, outputPending
, extractOutput
, removeOutput
, drainOutput
, dropOutput
, dropOutputBuffer
, dropInput
, dropInputBuffer
, volumeSame
, TimeStamp(..)
, InstrCluster
, Instr(..)
, Sample(..)
, Cluster(..)
, Volume(..)
, Event.T(..)
, Event.Data(..)
, NoteEv(..), Note(..), simpleNote
, CtrlEv(..), Ctrl(..)
, CustomEv(..), Custom(..)
, QueueEv(..)
, AddrEv(..)
, ConnEv(..), Connect
, EmptyEv(..)
) where
import qualified Sound.ALSA.Sequencer.Marshal.Sequencer as Seq
import Sound.ALSA.Sequencer.Marshal.Event as Event
import qualified Sound.ALSA.Exception as Exc
import Foreign.C.Types (CInt, )
import Foreign.Ptr (Ptr, nullPtr, )
import Foreign.Marshal.Alloc (alloca, )
import Foreign.Storable (peek, )
import Data.Word (Word, Word8, )
import Data.Int (Int16, )
syncOutputQueue :: Seq.T mode -> IO ()
syncOutputQueue (Seq.Cons h) =
Exc.checkResult_ "syncOutputQueue" =<< snd_seq_sync_output_queue h
foreign import ccall "alsa/asoundlib.h snd_seq_sync_output_queue"
snd_seq_sync_output_queue :: Ptr Seq.Core -> IO CInt
input :: Seq.AllowInput mode => Seq.T mode -> IO Event.T
input (Seq.Cons h) = alloca $ \p ->
do Exc.checkResult "input" =<< snd_seq_event_input h p
peek =<< peek p
foreign import ccall "alsa/asoundlib.h snd_seq_event_input"
snd_seq_event_input :: Ptr Seq.Core -> Ptr (Ptr Event.T) -> IO CInt
checkResult :: String -> CInt -> IO Word
checkResult loc n =
fmap fromIntegral $ Exc.checkResult loc n
inputPending
:: Seq.AllowInput mode
=> Seq.T mode
-> Bool
-> IO Word
inputPending (Seq.Cons h) fill =
checkResult "inputPending" =<< snd_seq_event_input_pending h (if fill then 1 else 0)
foreign import ccall "alsa/asoundlib.h snd_seq_event_input_pending"
snd_seq_event_input_pending :: Ptr Seq.Core -> Int -> IO CInt
output :: Seq.AllowOutput mode
=> Seq.T mode
-> Event.T
-> IO Word
output (Seq.Cons h) e =
Event.allocaEv e $ \p -> checkResult "output" =<< snd_seq_event_output h p
foreign import ccall "alsa/asoundlib.h snd_seq_event_output"
snd_seq_event_output :: Ptr Seq.Core -> Ptr Event.T -> IO CInt
outputBuffer :: Seq.AllowOutput mode
=> Seq.T mode
-> Event.T
-> IO Word
outputBuffer (Seq.Cons h) e =
Event.allocaEv e $ \p -> checkResult "outputBuffer" =<< snd_seq_event_output_buffer h p
foreign import ccall "alsa/asoundlib.h snd_seq_event_output_buffer"
snd_seq_event_output_buffer :: Ptr Seq.Core -> Ptr Event.T -> IO CInt
outputDirect
:: Seq.AllowOutput mode
=> Seq.T mode
-> Event.T
-> IO Word
outputDirect (Seq.Cons h) e =
Event.allocaEv e $ \p -> checkResult "outputDirect" =<< snd_seq_event_output_direct h p
foreign import ccall "alsa/asoundlib.h snd_seq_event_output_direct"
snd_seq_event_output_direct :: Ptr Seq.Core -> Ptr Event.T -> IO CInt
outputPending
:: Seq.AllowOutput mode
=> Seq.T mode
-> IO Word
outputPending (Seq.Cons h) =
fromIntegral `fmap` snd_seq_event_output_pending h
foreign import ccall "alsa/asoundlib.h snd_seq_event_output_pending"
snd_seq_event_output_pending :: Ptr Seq.Core -> IO CInt
extractOutput
:: Seq.AllowOutput mode
=> Seq.T mode
-> IO Event.T
extractOutput (Seq.Cons h) =
alloca $ \p -> do Exc.checkResult "extractOutput" =<< snd_seq_extract_output h p
peek =<< peek p
removeOutput :: Seq.AllowOutput mode
=> Seq.T mode -> IO ()
removeOutput (Seq.Cons h) = Exc.checkResult_ "removeOutput" =<< snd_seq_extract_output h nullPtr
foreign import ccall "alsa/asoundlib.h snd_seq_extract_output"
snd_seq_extract_output :: Ptr Seq.Core -> Ptr (Ptr Event.T) -> IO CInt
drainOutput
:: Seq.AllowOutput mode
=> Seq.T mode
-> IO Word
drainOutput (Seq.Cons h) = checkResult "drainOutput" =<< snd_seq_drain_output h
foreign import ccall "alsa/asoundlib.h snd_seq_drain_output"
snd_seq_drain_output :: Ptr Seq.Core -> IO CInt
dropOutput
:: Seq.AllowOutput mode
=> Seq.T mode -> IO ()
dropOutput (Seq.Cons h) = Exc.checkResult_ "dropOutput" =<< snd_seq_drop_output h
foreign import ccall "alsa/asoundlib.h snd_seq_drop_output"
snd_seq_drop_output :: Ptr Seq.Core -> IO CInt
dropOutputBuffer
:: Seq.AllowOutput mode
=> Seq.T mode -> IO ()
dropOutputBuffer (Seq.Cons h) = Exc.checkResult_ "dropOutputBuffer" =<< snd_seq_drop_output_buffer h
foreign import ccall "alsa/asoundlib.h snd_seq_drop_output_buffer"
snd_seq_drop_output_buffer :: Ptr Seq.Core -> IO CInt
dropInput
:: Seq.AllowInput mode
=> Seq.T mode -> IO ()
dropInput (Seq.Cons h) = Exc.checkResult_ "dropInput" =<< snd_seq_drop_input h
foreign import ccall "alsa/asoundlib.h snd_seq_drop_input"
snd_seq_drop_input :: Ptr Seq.Core -> IO CInt
dropInputBuffer
:: Seq.AllowInput mode
=> Seq.T mode -> IO ()
dropInputBuffer (Seq.Cons h) = Exc.checkResult_ "dropInputBuffer" =<< snd_seq_drop_input_buffer h
foreign import ccall "alsa/asoundlib.h snd_seq_drop_input_buffer"
snd_seq_drop_input_buffer :: Ptr Seq.Core -> IO CInt
simpleNote
:: Word8
-> Word8
-> Word8
-> Event.Note
simpleNote c n v =
Event.Note {
Event.noteChannel = c,
Event.noteNote = n,
Event.noteVelocity = v,
Event.noteOffVelocity = 0,
Event.noteDuration = 0
}
volumeSame :: Int16
volumeSame = 1