Using a Window or Thread to Manage Buffered Playback

The following messages can be sent to a window or thread for managing playback of MIDI system-exclusive messages or stream buffers.

Value Meaning
MM_MOM_CLOSE Sent when the device is closed by using the midiOutClose function.
MM_MOM_DONE Sent when the device driver is finished with a data block sent by using the midiOutLongMsg or midiStreamOut function.
MM_MOM_OPEN Sent when the device is opened by using the midiOutOpen function.

 

A wParam parameter and an lParam parameter are associated with each of these messages. The wParam parameter always specifies the handle of an open MIDI device. For MM_MOM_DONE, lParam specifies an address of a MIDIHDR structure identifying the completed data block. The lParam parameter is unused for MM_MOM_CLOSE and MM_MOM_OPEN.

The most useful message is probably MM_MOM_DONE. Unless you need to allocate memory or initialize variables, you probably do not need to process MM_MOM_OPEN and MM_MOM_CLOSE. When playback of a data block is complete, you can clean up and free the data block.