MidiOpen


Opening of MidiShare. MidiOpen allows the recording of some information relative to the application context (its name, the value of the global data register, etc.), to allocate a reception FIFO and to attribute a unique reference number to the application. In counterpart to any MidiOpen call, the application must call the MidiClose function before leaving, by giving its reference number as an argument. MidiShare can thus be aware of the precise number of active Midi applications.

pascal short    MidiOpen( MidiName applName );

applName
the name of the application.

The result is a unique reference number identifying the application.


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 */
}

MidiShare was originally developed for Pascal on the Macintosh. Consequently, 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");