MidiClose


This is used for closing of a MidiShare application. Every opening of MidiShare with MidiOpen must be matched by a call to MidiClose, so that MidiShare can keep track of active applications and release the corresponding internal data structures. All the MidiShare applications owning a "context alarm" will be informed of this closing.

pascal void    MidiClose (short refNum);

refNum
a 16-bit integer, it is the reference number of the application, given by the corresponding MidiOpen.


A do-nothing MidiShare application.


#include <MidiShare.h>
#include <stdio.h>

short    myRefNum;

main()
{
    if ( ! MidiShare() )     exit(1);        /* Check MidiShare loaded */
    myRefNum = MidiOpen("Sample");    /* Ask for a reference number */
    if ( myRefNum < 1 )     exit(1);        /* Check MidiOpen success */
    printf( "refNum : %i \n", myRefNum);    /* Print the reference number */
    MidiClose(myRefNum);            /* And close*/
}

MidiClose takes care of deleting all the connections of the concerned application. Therefore if an application sends some Midi events and without delay, does a MidiClose, these sent events will probably not be actually transmitted. They just go back to the MidiShare Memory Manager.

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

myRefNum = MidiOpen("\pSample");