Segments
The basic chunk of data in DirectMusic is called a segment. A segment is represented by an IDirectMusicSegment interface. You can create a segment in any of the following ways:
- Load a file or resource object that supports the IDirectMusicSegment interface. For more information, see DirectMusic Loader.
- Get a motif from a style by using the IDirectMusicStyle::GetMotif method.
- Use methods of the IDirectMusicComposer interface to create a composition or transition at run time. For more information, see Overview of Programming for Composition and Using Transitions.
- Make a copy of an existing segment by using the IDirectMusicSegment::Clone method.
- Construct a segment from existing tracks. Create a segment object by calling CoCreateInstance, and then add tracks by calling IDirectMusicSegment::InsertTrack.
- Use the IDirectMusicBand::CreateSegment method. This creates a special type of secondary segment that is used only for making band changes. For more information, see Making Band Changes Programmatically.
Each segment consists of one or more tracks, each represented by an IDirectMusicTrack interface. Tracks contain most of the data for the segment, whether that data consists of note events, band changes, tempo changes, or other timed events. Applications generally do not need to use this interface because the tracks are managed through the segment object. For more information, see Tracks.
Segments can serve different purposes. The following are the kinds of segments that you are most likely to use:
- Primary segment. A piece of music such as a MIDI file, a segment authored in DirectMusic Producer, or a segment formed at run time by the composer object.
- Motif segment. A short piece of music to be played over the primary segment. Motifs are part of a style object, but you can also create short secondary segments from other sources and play them over the primary segment like motifs.
- Band segment. A set of instruments and instrument settings for the various channels in the performance. The application can play a band segment to execute changes in the band performing the music.
- Template segment. A guide to chord progressions, groove levels, and embellishments, used in conjunction with a style and chord map to compose music at run time. Unlike other segments, a template segment is never played directly by an application; instead, it is passed to the composer object to be used in creating a musical segment.
The playback of segments is controlled by the IDirectMusicPerformance interface and begins with a call to IDirectMusicPerformance::PlaySegment. An instance of a playing segment is represented by an IDirectMusicSegmentState interface, which can be used to retrieve information about the current state of the segment.
Only one primary segment can play inside a performance. When you cue a primary segment for playback, you can specify that it is to be played after the currently playing segment is finished, or you can use it to replace the current primary segment.
Secondary segments, on the other hand, play over the current primary segment, and any number of secondary segments can be playing simultaneously.
Secondary segments do not normally alter the performance of the primary segment. For example, a secondary segment can be based on a different style without affecting the style of the primary segment.
However, a secondary segment can be designated as a control segment, in which case it takes over the task of responding to IDirectMusicPerformance::SetParam and IDirectMusicPerformance::GetParam calls, which normally go to tracks in the primary segment. Thus a control segment might control the current chord or groove level. For more information, see Tracks.
For more information about playing secondary segments as control segments, see DMUS_SEGF_FLAGS.
For more information about segment playback, see Segment Timing.
Last updated on Monday, April 12, 2004
© 1992-2002 Microsoft Corporation. All rights reserved.