---------------------------------------------------------------------------------- |-- Module : Sound.ALSA.Sequencer.Event-- Copyright : (c) Henning Thielemann, 2010-- (c) Iavor S. Diatchki, 2007-- License : BSD3---- Maintainer: Iavor S. Diatchki-- Stability : provisional---- This module contains functions for working with events.-- Reference:-- <http://www.alsa-project.org/alsa-doc/alsa-lib/group___seq_event.html>--------------------------------------------------------------------------------moduleSound.ALSA.Sequencer.Event(syncOutputQueue,input,inputPending,output,outputBuffer,outputDirect,outputPending,extractOutput,removeOutput,drainOutput,dropOutput,dropOutputBuffer,dropInput,dropInputBuffer,TimeStamp(..),InstrCluster,Instr(..),Sample(..),Cluster(..),Volume(..),volumeSame,Event.T(..),simple,Event.Data(..),NoteEv(..),Note(..),simpleNote,CtrlEv(..),Ctrl(..),CustomEv(..),Custom(..),QueueEv(..),AddrEv(..),ConnEv(..),Connect,EmptyEv(..))whereimportqualifiedSound.ALSA.Sequencer.AddressasAddrimportqualifiedSound.ALSA.Sequencer.QueueasQueueimportqualifiedSound.ALSA.Sequencer.Marshal.SequencerasSeqimportSound.ALSA.Sequencer.Marshal.EventasEventimportqualifiedSound.ALSA.ExceptionasExcimportForeign.C.Types(CInt,)importForeign.Ptr(Ptr,nullPtr,)importForeign.Marshal.Alloc(alloca,)importForeign.Storable(peek,)importData.Word(Word,Word8,)importData.Int(Int16,)-- | Wait until all events of the client are processed.syncOutputQueue::Seq.Tmode->IO()syncOutputQueue(Seq.Consh)=Exc.checkResult_"syncOutputQueue"=<<snd_seq_sync_output_queuehforeignimportccallsafe"alsa/asoundlib.h snd_seq_sync_output_queue"snd_seq_sync_output_queue::PtrSeq.Core->IOCInt-- | Get an event from the input buffer.-- If the input buffer is empty, then it is filled with data from the-- sequencer queue. If there is no data in the sequencer queue,-- then the process is either put to sleep (if the sequencer is operating-- in blocking mode), or we throw @EAGAIN@ (if the sequence is operating-- in non-blocking mode).---- We may also throw @ENOSPC@, which means that the sequencer queue-- over-run and some events were lost (this clears the input buffer).--input::Seq.AllowInputmode=>Seq.Tmode->IOEvent.Tinput(Seq.Consh)=alloca$\p->doExc.checkResult_"input"=<<snd_seq_event_inputhppeek=<<peekpforeignimportccallsafe"alsa/asoundlib.h snd_seq_event_input"snd_seq_event_input::PtrSeq.Core->Ptr(PtrEvent.T)->IOCIntcheckResult::String->CInt->IOWordcheckResultlocn=fmapfromIntegral$Exc.checkResultlocn-- | Returns the number of events in the input buffer.-- If the input buffer is empty and the boolean argument is true,-- then try to fill the input buffer with data from the sequencer queue.-- See also: 'input'.inputPending::Seq.AllowInputmode=>Seq.Tmode->Bool-- ^ refill if empty?->IOWord-- ^ number of events in bufferinputPending(Seq.Consh)fill=checkResult"inputPending"=<<snd_seq_event_input_pendingh(iffillthen1else0)foreignimportccallunsafe"alsa/asoundlib.h snd_seq_event_input_pending"snd_seq_event_input_pending::PtrSeq.Core->Int->IOCInt-- | Output an event and drain the buffer, if it became full.-- Throws exceptions.-- See also: 'outputDirect', 'outputBuffer',-- 'outputPending', 'drainOutput', 'dropOutput',-- 'extractOutput', 'removeEvents'output::Seq.AllowOutputmode=>Seq.Tmode->Event.T->IOWord-- ^ the number of remaining events (or bytes?)output(Seq.Consh)e=Event.allocaEve$\p->checkResult"output"=<<snd_seq_event_outputhpforeignimportccallsafe"alsa/asoundlib.h snd_seq_event_output"snd_seq_event_output::PtrSeq.Core->PtrEvent.T->IOCInt-- | Output an event without draining the buffer.-- Throws @-EAGAIN@ if the buffer becomes full.-- See also 'output'.outputBuffer::Seq.AllowOutputmode=>Seq.Tmode->Event.T->IOWord-- ^ the byte size of remaining eventsoutputBuffer(Seq.Consh)e=Event.allocaEve$\p->checkResult"outputBuffer"=<<snd_seq_event_output_bufferhpforeignimportccallunsafe"alsa/asoundlib.h snd_seq_event_output_buffer"snd_seq_event_output_buffer::PtrSeq.Core->PtrEvent.T->IOCInt-- | Output an event directly to the sequencer, NOT through the output buffer.-- If an error occurs, then we throw an exception.-- See also 'output'.outputDirect::Seq.AllowOutputmode=>Seq.Tmode->Event.T->IOWord-- ^ number of bytes sent to the sequenceroutputDirect(Seq.Consh)e=Event.allocaEve$\p->checkResult"outputDirect"=<<snd_seq_event_output_directhpforeignimportccallsafe"alsa/asoundlib.h snd_seq_event_output_direct"snd_seq_event_output_direct::PtrSeq.Core->PtrEvent.T->IOCInt-- | Return the size (in bytes) of pending events on output buffer.-- See also 'output'.outputPending::Seq.AllowOutputmode=>Seq.Tmode->IOWord-- ^ size of pending events (in bytes)outputPending(Seq.Consh)=fromIntegral`fmap`snd_seq_event_output_pendinghforeignimportccallunsafe"alsa/asoundlib.h snd_seq_event_output_pending"snd_seq_event_output_pending::PtrSeq.Core->IOCInt-- | Extract the first event in output buffer.-- Throws an exception on error.-- See also 'output'.extractOutput::Seq.AllowOutputmode=>Seq.Tmode->IOEvent.T-- ^ the first event in the buffer (if one was present)extractOutput(Seq.Consh)=alloca$\p->doExc.checkResult_"extractOutput"=<<snd_seq_extract_outputhppeek=<<peekp-- | Remove the first event in output buffer.-- Throws an exception on error.-- See also 'output'.removeOutput::Seq.AllowOutputmode=>Seq.Tmode->IO()removeOutput(Seq.Consh)=Exc.checkResult_"removeOutput"=<<snd_seq_extract_outputhnullPtrforeignimportccallunsafe"alsa/asoundlib.h snd_seq_extract_output"snd_seq_extract_output::PtrSeq.Core->Ptr(PtrEvent.T)->IOCInt-- | Drain output buffer to sequencer.-- This function drains all pending events on the output buffer.-- The function returns immediately after the events are sent to the queues-- regardless whether the events are processed or not.-- To get synchronization with the all event processes,-- use 'syncOutputQueue' after calling this function.-- Throws an exception on error.-- See also: 'output', 'syncOutputQueue'.drainOutput::Seq.AllowOutputmode=>Seq.Tmode->IOWord-- ^ byte size of events remaining in the buffer.drainOutput(Seq.Consh)=checkResult"drainOutput"=<<snd_seq_drain_outputhforeignimportccallsafe"alsa/asoundlib.h snd_seq_drain_output"snd_seq_drain_output::PtrSeq.Core->IOCInt-- | Remove events from both the user-space output buffer,-- and the kernel-space sequencer queue.-- See also: 'drainOutput', 'dropOutputBuffer', 'removeEvents'.dropOutput::Seq.AllowOutputmode=>Seq.Tmode->IO()dropOutput(Seq.Consh)=Exc.checkResult_"dropOutput"=<<snd_seq_drop_outputhforeignimportccallunsafe"alsa/asoundlib.h snd_seq_drop_output"snd_seq_drop_output::PtrSeq.Core->IOCInt-- | Remove events from the user-space output buffer.-- See also: 'dropOutput'.dropOutputBuffer::Seq.AllowOutputmode=>Seq.Tmode->IO()dropOutputBuffer(Seq.Consh)=Exc.checkResult_"dropOutputBuffer"=<<snd_seq_drop_output_bufferhforeignimportccallunsafe"alsa/asoundlib.h snd_seq_drop_output_buffer"snd_seq_drop_output_buffer::PtrSeq.Core->IOCInt-- | Remove events from both the user-space input buffer,-- and the kernel-space sequencer queue.-- See also: 'dropInputBuffer', 'removeEvents'.dropInput::Seq.AllowInputmode=>Seq.Tmode->IO()dropInput(Seq.Consh)=Exc.checkResult_"dropInput"=<<snd_seq_drop_inputhforeignimportccallunsafe"alsa/asoundlib.h snd_seq_drop_input"snd_seq_drop_input::PtrSeq.Core->IOCInt-- | Remove events from the user-space input buffer.-- See also: 'dropInput'.dropInputBuffer::Seq.AllowInputmode=>Seq.Tmode->IO()dropInputBuffer(Seq.Consh)=Exc.checkResult_"dropInputBuffer"=<<snd_seq_drop_input_bufferhforeignimportccallunsafe"alsa/asoundlib.h snd_seq_drop_input_buffer"snd_seq_drop_input_buffer::PtrSeq.Core->IOCInt-- | Make a note whose unspecified fields contain 0.simpleNote::Word8-- ^ Channel.->Word8-- ^ Note.->Word8-- ^ Velocity.->Event.NotesimpleNotecnv=Event.Note{Event.noteChannel=c,Event.noteNote=n,Event.noteVelocity=v,Event.noteOffVelocity=0,Event.noteDuration=0}{- |
Construct an ALSA sequencer event from very few information.
Most fields are initialized with sensible defaults.
You may use this as a start and alter its fields for your special needs.
> (Event.simple myAddr (Event.simpleNote 0 60 64)) {Event.dest = destAddr}
-}simple::Addr.T->Event.Data->Event.Tsimplesrcbdy=Cons{Event.highPriority=False,Event.tag=0,Event.queue=Queue.direct,Event.timestamp=Event.TickTime0,Event.source=src,Event.dest=Addr.subscribers,Event.body=bdy}-- | Used for volume control: means do not change the volume.volumeSame::Int16volumeSame=-1