Microsoft DirectX 8.1 (Visual Basic) |
The PlayMotif sample demonstrates how a motif played as a secondary segment can be aligned to the rhythm of the primary segment in various ways.
Source: (SDK root)\Samples\Multimedia\VBSamples\DirectMusic\PlayMotif
Executable: (SDK root)\Samples\Multimedia\VBSamples\DirectMusic\Bin
Play the default segment, or load another DirectMusic Producer segment that contains motifs. Select one of the patterns in the list box and one of the Align Option buttons, and then click Play Motif. Note how the motif does not begin playing until an appropriate boundary in the primary segment has been reached.
Information about the motifs is contained in an array of user-defined types, which is initialized in the LoadSegment procedure. When a motif is played, it is aligned to the primary segment's rhythm by passing one of the CONST_DMUS_SEGF_FLAGS to DirectMusicPerformance8.PlaySegmentEx, in the cmdPlayMotif_Click procedure.
Notifications are used to keep the user interface up to date. Of particular interest is the way the segment state is retrieved from the User member of the DMUS_NOTIFICATION_PMSG type, so that the application can ascertain which motif started or stopped.