Typically a DirectMusic application obtains musical data from one or more of the following sources:
Data from these sources is encapsulated in DirectMusicSegment objects. Each segment object represents data from a single source. At any given moment in a performance, one or more segments may be playing: a primary segment and possibly one or more secondary segments. Source files can be mixed—for example, a secondary segment based on a MIDI file can be played along with a primary segment based on an authored segment file.
A segment comprises several tracks, each containing timed data of a particular kind—for example, notes or tempo changes.
Most tracks generate messages when the segment is played by the performance, and the performance dispatches the messages to any application-defined tools, which have the opportunity to modify messages and pass them on, delete messages, and send new messages. Tools are grouped in segment graphs that process only messages from their own segments, and a performance graph that accepts messages from all segments.
Finally, the messages are delivered to the output tool, which converts the data to MIDI format before passing it to a port. Channel-specific MIDI messages are directed to the appropriate channel group on the port. The port synthesizes a sound wave that is streamed to a wave output device (normally a DirectSound buffer).
The following diagram gives an overview of how musical data gets from files to the wave output device. For the sake of simplicity, only a single segment is shown. Note that this segment gets its data from only one of the three possible sources shown: either a MIDI file, an authored segment file, or component files combined by the DirectMusicComposer object.
For a closer look at the flow of messages through the performance, see DirectMusic Messages.
For information on how to implement the process illustrated in the diagram, see the DirectMusic Essentials section, in particular the topics DirectMusic Loader and Playing Music.
For more about segment and component files, see Music Composition.