MidiAddField


Adds a field at the tail of an event of variable length (for example a System Exclusive or a Stream) and assigns to it the value transmitted as a parameter.

pascal void    MidiAddField (MidiEvPtr e, long v);

e
a MidiEvPtr, it is a pointer to the event to be modified.
v
a 32-bit integer, it is the value of the field to be added. This value is always a long for a purpose of uniformity, but it is internally translate to the right size (a byte in this case). The value of v is actually between 0 and 127 for a System Exclusive and between 0 and 255 for a Stream.


Creates the System Exclusive message "F0 67 18 05 F7".


MidiEvPtr    e;

e = MidiNewEv (typeSysEx);
MidiAddField (e, 0x67L);
MidiAddField (e, 0x18L);
MidiAddField (e, 0x05L);

the leading F0 byte and the tailing F7 byte are automatically added by MidiShare when the message is transmitted. They must not be added by the user.


Creates the Stream message "F8 F0 67 F8 18 05 F7" that mixes two MidiClock messages (F8) into a System Exclusive.


MidiEvPtr    e;
long     i;

e = MidiNewEv(typeStream);
MidiAddField (e, 0xF8L);
MidiAddField (e, 0xF0L);
MidiAddField (e, 0x67L);
MidiAddField (e, 0xF8L);
MidiAddField (e, 0x18L);
MidiAddField (e, 0x05L);
MidiAddField (e, 0xF7L);

Streams are sent without any transformation (no running status, no check of coherence). They can be used for example to send a long system exclusive split into several chunks with a little delay between. They can also be used as in the example to mix real time messages in a long system exclusive for maintaining synchronization.


Create a system exclusive message from an array of values.


char        tab[3] = {10, 20, 30};
MidiEvPtr    aSysEx;

MidiEvPtr Array2SysEx( short len, char* vect, short chan, short port )
{
    MidiEvPtr e;
    
    e = MidiNewEv( typeSysEx );        /* a new, empty sysex    */
    Chan(e) = chan; Port(e) = port;        /* set destination info    */
    while (lenั) MidiAddField(e, *vect++);    /* append fields    */
    return e;
}

aSysEx = Array2SysEx(3, tab, 0, 0);