Segment Timing
Segments play from the beginning, unless a start point is set by a call to the IDirectMusicSegment::SetStartPoint method. If a repeat count is set by using IDirectMusicSegment::SetRepeats, the entire segment will repeat that number of times, unless a loop has been defined by a call to IDirectMusicSegment::SetLoopPoints, in which case only the part of the segment between the loop points will repeat.
The performance time at which the segment starts playing is determined by two parameters of IDirectMusicPerformance::PlaySegment:
- The i64StartTime parameter sets the earliest time at which the segment can start playing. If i64StartTime is 0, this time is as soon as possible. The actual time when the segment will start depends on the type of segment. If it is a primary or control segment, the earliest start time is at queue (or flush) time. If it is a non-control secondary segment, the earliest start is at latency time. For more information on queue time and latency time, see Latency and Bumper Time.
- The dwFlags parameter determines how soon after the scheduled time the segment should actually start playing, depending on the rhythm of the currently playing segment. Most often you will want to wait for an appropriate moment before introducing a new segment, a transition, or a motif. You control the delay by setting one of the following DMUS_SEGF_FLAGS:
- DMUS_SEGF_AFTERPREPARETIME
- Play at the earliest start time plus the prepare time. This ensures that any messages from the currently playing segment that have already been queued to the port are not invalidated. This saves processing time and also ensures that any motifs continue to play smoothly over a transition from one primary segment to another.
- DMUS_SEGF_GRID
- Play on a grid boundary. A grid is a subdivision of a beat. The time signature (authored into the style) determines how many grids each beat is divided into.
- DMUS_SEGF_BEAT
- Play on a beat.
- DMUS_SEGF_MEASURE
- Play at the beginning of a measure.
- DMUS_SEGF_DEFAULT
- Use the cued segment's default boundary. You can set this value by using the IDirectMusicSegment::SetDefaultResolution method.
If none of these flags is set, the segment will start playing at exactly the earliest start time.