Platform SDK: DirectX

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 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 can also place messages in the queue directly. You might do this, for example, to change the tempo.

[C++]

For sample code, see IDirectMusicPerformance::SendPMsg.

[Visual Basic]

For sample code, see the DLSEffects sample.

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 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 message.

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, in which 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 tell the performance how to convert music time to reference time. Time-signature messages are purely informational, because the time signature is built into the segment and cannot be changed.

[C++]

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 wants to pass it on, has the graph stamp the message with a pointer to the next tool. For more information, 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. This flag is based on what delivery type the tool is expecting, as follows:

The current tool can change the delivery type after the graph has 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 that it receives into standard MIDI messages and delivers these to the synthesizer through the port buffer.