typeInstrName (code 138)


An instrument name event (from the Midi File 1.0 specification). This event cannot be sent to external Midi devices.

typeInstrName events have a variable number of character fields.


Creates a typeInstrName event from a character string and returns a pointer to the event or NIL if there is not enough memory space.


MidiEvPtr InstrName ( long date, char *s, short chan, short port)
{
    MidiEvPtr e;
    long    c=0;

    if ( e = MidiNewEv(typeInstrName) )    /* Allocate a new event. Check not NIL */ 
    {
        Date(e) = date;        /* These information are common to all */
        Chan(e) = chan;        /* kind of events */
        Port(e) = port;
        for (c=0; *s; s++, c++)     /* Build the event while counting the */
            MidiAddField(e ,*s);/* characters of the original string */
        if (c != MidiCountFields(e)) {    /* Check the length of the event*/
            MidiFreeEv(e);        /* if we run out of memory : free the */
            return 0;            /* event and return NIL */
        }
    }
    return e;
}


Converts a typeInstrName event into a character string. Assume s is big enough.


void GetText (MidiEvPtr e, char *s)
{
    short c=0, i=0;
    
    c = MidiCountFields(e);
    while (i<c) *s++ = MidiGetField(e, i++);
    *s = 0;
}