Microsoft DirectX 8.0 (C++) |
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)\Sample\Multimedia\DirectMusic\PlayMotif
Executable: (SDK Root)\Sample\Multimedia\DirectMusic\Bin
Play the default segment, or load another DirectMusic segment based on a style 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.
The PlayMotif sample is very similar in form to the PlayAudio sample. For detailed programming notes on the basics of this sample, see PlayAudio.
When loading the file, PlayMotif performs the same steps as PlayAudio, with the following additions in the LoadSegmentFile function:
Passes the motif name to IDirectMusicStyle8::GetMotif to get an IDirectMusicSegment8 interface pointer to the motif, and stores this as data associated with the item in the list box.
When Play Motif is clicked, the OnPlayMotif function performs the following tasks:
DirectMusic notifications are handled much as in PlayAudio, but this application also takes note of any motif starting or stopping and updates the play count in the MOTIF_NODE structure. If the play count is greater than zero then it updates the user interface to show that the motif is playing.