Duplicates an event, taking into account the structure of the event. It can be used to copy any type of events, from simple notes to large system exclusives.
pascal MidiEvPtr MidiCopyEv (MidiEvPtr e);
e
- a MidiEvPtr, is a pointer to the event to be copied.
The result is a MidiEvPtr, a pointer to the copy if the operation was successful. The result is NIL if MidiShare was not able to allocate enough memory space for the copy.
Send from now, 10 times an identical note of pitch 60 every 250 ms.
MidiEvPtr e; short myRefNum; long d; short i; /* ....... */ e = MidiNewEv (typeNote); /* create template note */ Pitch(e)= 60; /* fill up its parameters */ Vel(e) = 80; Dur(e) = 250; Chan(e) = 0; Port(e) = 0; for (d=MidiGetTime(), i=0; i<10; i++, d+=250) /* send the 10 copies */ MidiSendAt (myRefNum, MidiCopyEv(e), d); /* of the template */ MidiFreeEv(e); /* and free the template */
it is very important that, once an event is sent, it must never be used again by the application. Therefore, if an application needs to send the same event several times duplicate copies must be used.