MidiGetEv


Extracts the first event on in the reception FIFO. The received events, stored automatically by MidiShare in the application reception FIFO, can be picked up by successive calls to MidiGetEv function.

pascal MidiEvPtr    MidiGetEv (short refNum); 

refNum
a 16-bit integer, is the reference number of the application.

A MidiEvPtr, is a pointer to the first event in the reception FIFO, or NIL if the FIFO is empty. The event is extracted from the reception FIFO.


A receive alarm that processes all the received events by adding to their date a one second delay.


void OneSecDelay (short refNum)
{
    MidiEvPtr    e;
    long n;
    for ( n = MidiCountEvs(refNum); n > 0; Ñn ) 
    {                                
        e = MidiGetEv(refNum);    /* Get an event from the FIFO */
        Date(e) += 1000;        /* Add 1000 ms to its date */
        MidiSend(refNum,e);        /* Then send the event */
    }
}

/* ....... */

MidiSetRcvAlarm(myRefNum,OneSecDelay); /* Activate the receive alarm */

such a function can be called repeatedly in the main event loop of the application, but for really accurate time control, it must be installed as a receive alarm with MidiSetRcvAlarm.

MidiShare was originally developed for Pascal on the Macintosh. Therefore, in C, all functions passed as arguments of a MidiShare function must be declared as Pascal. In the previous example, OneSecDelay must be declared as:

pascal void OneSecDelay (short refNum);