mdSend(3dm) mdSend(3dm)
mdSend - send out MIDI data
#include <dmedia/midi.h>
int mdSend(MDport port, MDevent *buf, int count)
mdSend writes MIDI events to the interface indicated by port. buf points
to a user-allocated array containing at least count MDevent structures.
mdSend will always transmit count events; it will block if necessary
waiting for the interface event queue to drain.
The event structure contains the MIDI message to be transmitted in the
msg field (see mdIntro(3dm) for details on the MDevent structure). If
the application wishes to transmit a system exclusive message, it should
set msg[0] to MD_SYSEX (0xF0), point sysexmsg to the block of sysex data,
and set msglen to the length of the sysex data. It is possible for a
system exclusive message to be transmitted in multiple segments, but the
first byte in the first sysexmsg chunk must contain MD_SYSEX, and the
last byte in the last sysexmsg chunk must be MD_EOX.
The current implementation of the library cannot properly merge multiple
streams of system exclusive data transmitted to the same interface. For
best results no more than one port should transmit system exclusive data
to an interface at any given time.
The stamp field of the event governs when that event will be transmitted.
Event stamps must be greater than or equal to 0. The interpretation of a
stamp depends on the stamping mode of the port (see mdSetStampMode(3dm)).
If the port's stamp mode is MD_NOSTAMP, the event will be transmitted
immediately. If the stamp mode is MD_RELATIVESTAMP or MD_DELTASTAMP, the
stamp value is in milliseconds. In MD_RELATIVETICKS or MD_DELTATICKS
mode, the stamp value is in ticks. When in one of the relative stamp
modes, the time stamps of the events must increase monotonically. In
these modes (MD_RELATIVETICKS and MD_RELATIVESTAMP), if an application
sends an event whose timestamp is less than that of its predecessor, the
event will be transmitted immediately.
If the MIDI interface's event queue is full when mdSend is called, mdSend
will block until space if available. To avoid blocking, and application
can call select(3) (see mdGetFd).
mdSend returns the number of messages actually sent on success or -1
times the number of messages sent on error. Note that a return value of
0 indicates that an error occurred and that no messages were sent. The
following error codes are possible:
Page 1
mdSend(3dm) mdSend(3dm)
ENXIO - A bad MDport was passed to mdSend
EFAULT - An invalid address was passed to the MIDI driver
EINVAL - An undefined operation was called.
mdIntro(3dm), mdSetStampMode(3dm), mdGetFd, select(2)
PPPPaaaaggggeeee 2222 [ Back ]
|