Message Creation and Delivery

When a segment is played, most of its tracks generate messages containing information about events that are to take place during the playback. (For more information, see Tracks.)

A few tracks send more than one kind of message. For example, a style track sends note messages and time signature messages. In such cases, an application can disable certain kinds of messages in the track. For more information, see Setting and Retrieving Track Parameters.

Applications may also place messages in the queue directly. You might do this, for example, to change the tempo. For sample code, see IDirectMusicPerformance::SendPMsg.

The performance engine determines when each message is to be processed in real time (reference time). In the case of channel messages, the performance also determines to what PChannel the message is to be directed. This information, along with other data including the message type, its source track, and pointers to the first graph and tool that are to receive the message, are stored in the DMUS_PMSG members of the message structure.

Certain messages, such as tempo and time signature changes, are immediately processed and freed by the performance. Other messages, such as notes and patch changes, are placed in a queue, where they are processed in order of time-stamp.

Notes  There is no guarantee that messages with the same time-stamp will be processed in any particular order.

Tempo messages (DMUS_TEMPO_PMSG) tell the performance how to convert music time to reference time. Time signature messages (DMUS_TIMESIG_PMSG) are purely informational, because the time signature is built into the segment and cannot be changed.

Messages are first sent to any tools in the segment's graph and then to tools in the performance's graph. (The application is responsible for creating either or both of these graphs and defining the tools. There is no default graph.)

The first tool in a graph processes the message and then, if it wishes to pass it on, has the graph stamp the message with a pointer to the next tool. (For a closer look at this process, see Tutorial 2: Using Tools.)

At this point the graph also flags the message with a delivery type that determines when the message is delivered to the next tool. The flag is based on what delivery type the tool is expecting, as follows:

The current tool has the opportunity to change the delivery type after the graph is finished stamping and flagging the message.

Ultimately, unless a message has been discarded, it arrives at the DirectMusic output tool, which converts all the data it receives into standard MIDI messages and delivers these to the synthesizer through the port buffer.