Platform SDK: DirectX

Step 7: Transition to Another Primary Segment

[Visual Basic]

This tutorial pertains only to applications written in C++. See DirectMusic Visual Basic Tutorials.

[C++]

DMDonuts cues a different primary segment in two places: when the game level changes, and when the first hit is made on a donut on any level. The following code is from the CheckForHits function. When the function finds that a hit is the first to have occurred on this level, it tells the DirectMusic composer to create a transition from the current (introductory) theme to the action theme. The call to IDirectMusicComposer::AutoTransition also cues the transition and the following action segment so that they play automatically; in this case, the transition will start on the next measure boundary.

if (gapSegment[SEGMENT_TRANS_1])
{
    gapSegment[SEGMENT_TRANS_1]->Release();
}
gpComposer->AutoTransition(
        gpPerformance,                 // The performance
        gapSegment[SEGMENT_2],         // The next primary segment
        DMUS_COMMANDT_FILL,            // Embellishment type
        DMUS_COMPOSEF_MODULATE |       // Modulate to new key
        DMUS_COMPOSEF_MEASURE,         // and start on measure
        gapChordMap[gnCurrentStyle] [gnCurrentChordMap], 
                                       // Use current chordmap
        &gapSegment[SEGMENT_TRANS_1],  // Created transition segment
        NULL, NULL                     // No segment states needed
);
 

Note that you don't have to stop the first segment. It stops automatically when a transition or new primary segment is played.

Next: Step 8: Play a Motif