Copyright | (c) Henning Thielemann 2011 (c) Iavor S. Diatchki 2007 |
---|---|
License | BSD3 |
Maintainer | Henning Thielemann |
Stability | provisional |
Safe Haskell | None |
Language | Haskell2010 |
This module contains functions for working with events. Reference: http://www.alsa-project.org/alsa-doc/alsa-lib/group___seq_event.html
- output :: AllowOutput mode => T mode -> T -> IO Word
- outputBuffer :: AllowOutput mode => T mode -> T -> IO Word
- outputDirect :: AllowOutput mode => T mode -> T -> IO Word
- outputPending :: AllowOutput mode => T mode -> IO Word
- extractOutput :: AllowOutput mode => T mode -> IO T
- removeOutput :: AllowOutput mode => T mode -> IO ()
- drainOutput :: AllowOutput mode => T mode -> IO Word
- dropOutput :: AllowOutput mode => T mode -> IO ()
- dropOutputBuffer :: AllowOutput mode => T mode -> IO ()
- syncOutputQueue :: T mode -> IO ()
- input :: AllowInput mode => T mode -> IO T
- inputPending :: AllowInput mode => T mode -> Bool -> IO Word
- dropInput :: AllowInput mode => T mode -> IO ()
- dropInputBuffer :: AllowInput mode => T mode -> IO ()
- data T = Cons {}
- simple :: T -> Data -> T
- forSourcePort :: T -> Data -> T
- forConnection :: T -> Data -> T
- data Data
- class Type e
- data NoteEv
- data Note = Note {
- noteChannel :: !Channel
- noteNote :: !Pitch
- noteVelocity :: !Velocity
- noteOffVelocity :: !Velocity
- noteDuration :: !Duration
- simpleNote :: Channel -> Pitch -> Velocity -> Note
- data CtrlEv
- data Ctrl = Ctrl {}
- data CustomEv
- data Custom = Custom {}
- customZero :: Custom
- data ExtEv
- data QueueEv
- = QueueStart
- | QueueContinue
- | QueueStop
- | QueueSetPosTick !Tick
- | QueueSetPosTime !T
- | QueueTempo !Tempo
- | QueueClock
- | QueueTick
- | QueueSkew !Skew
- | QueueSyncPos !Position
- data AddrEv
- data ConnEv
- data EmptyEv
- = TuneRequest
- | Reset
- | Sensing
- | None
- | Unknown
- newtype Tag = Tag {}
- newtype Tempo = Tempo {}
- newtype Parameter = Parameter {}
- newtype Value = Value {}
- newtype Channel = Channel {}
- newtype Pitch = Pitch {}
- newtype Velocity = Velocity {
- unVelocity :: Word8
- normalVelocity :: Velocity
- offVelocity :: Velocity
- newtype Duration = Duration {
- unDuration :: Word32
Output
If you send an event but you do not hear something, then check the following conditions:
- Check whether your event was actually delivered.
E.g. use the event monitor
aseqdump
in order to see sent messages. - If the message was not delivered,
maybe you quit the program too early
and thus destroyed pending messages.
Use
syncOutputQueue
at the end of the program in order to wait for all messages to be sent. - Make sure the sequencer supports output and the target port supports input.
- Make sure to setup a connection to the receiver.
- Make sure to have called
drainOutput
afteroutput
. - If you use a timestamp in an event, make sure you also declare a queue (and create one before).
- Make sure you started the queue you used for sending.
- Be aware of that
QueueStart
clears the queue before running the queue. That is, events sent beforeQueueStart
are deleted. If you want to keep these events, then useQueueContinue
instead.
:: AllowOutput mode | |
=> T mode | |
-> T | |
-> IO Word | the number of remaining events (or bytes?) |
Output an event and drain the buffer, if it became full.
Throws exceptions.
See also: outputDirect
, outputBuffer
,
outputPending
, drainOutput
, dropOutput
,
extractOutput
, removeOutput
:: AllowOutput mode | |
=> T mode | |
-> T | |
-> IO Word | the byte size of remaining events |
Output an event without draining the buffer.
Throws -EAGAIN
if the buffer becomes full.
See also output
.
:: AllowOutput mode | |
=> T mode | |
-> T | |
-> IO Word | number of bytes sent to the sequencer |
Output an event directly to the sequencer, NOT through the output buffer.
If an error occurs, then we throw an exception.
See also output
.
:: AllowOutput mode | |
=> T mode | |
-> IO Word | size of pending events (in bytes) |
Return the size (in bytes) of pending events on output buffer.
See also output
.
:: AllowOutput mode | |
=> T mode | |
-> IO T | the first event in the buffer (if one was present) |
Extract the first event in output buffer.
Throws (Errno 2)
exception if output buffer is empty.
See also output
.
removeOutput :: AllowOutput mode => T mode -> IO () Source #
Remove the first event in output buffer.
Throws an exception on error.
See also output
.
:: AllowOutput mode | |
=> T mode | |
-> IO Word | byte size of events remaining in the buffer. |
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
.
dropOutput :: AllowOutput mode => T mode -> IO () Source #
Remove events from both the user-space output buffer,
and the kernel-space sequencer queue.
See also: drainOutput
, dropOutputBuffer
, removeOutput
.
dropOutputBuffer :: AllowOutput mode => T mode -> IO () Source #
Remove events from the user-space output buffer.
See also: dropOutput
.
syncOutputQueue :: T mode -> IO () Source #
Wait until all events of the client are processed.
Input
input :: AllowInput mode => T mode -> IO T Source #
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).
:: AllowInput mode | |
=> T mode | |
-> Bool | refill if empty? |
-> IO Word | number of events in buffer |
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
.
dropInput :: AllowInput mode => T mode -> IO () Source #
Remove events from both the user-space input buffer,
and the kernel-space sequencer queue.
See also: dropInputBuffer
, removeOutput
.
dropInputBuffer :: AllowInput mode => T mode -> IO () Source #
Remove events from the user-space input buffer.
See also: dropInput
.
Data types
simple :: T -> Data -> T Source #
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 (Event.Channel 0) (Event.Pitch 60) Event.normalVelocity)) {Event.dest = destAddr}
expEv
Note | |
|
simpleNote :: Channel -> Pitch -> Velocity -> Note Source #
Make a note whose unspecified fields contain 0.
customZero :: Custom Source #
QueueStart | |
QueueContinue | |
QueueStop | |
QueueSetPosTick !Tick | |
QueueSetPosTime !T | |
QueueTempo !Tempo | |
QueueClock | |
QueueTick | |
QueueSkew !Skew | |
QueueSyncPos !Position |