Microsoft DirectX 9.0

Using Styles

The DirectMusic style object represents a collection of musical patterns, usually including embellishments and motifs, with a time signature, tempo, and band. It defines the basic rhythm and the notes to be played in each instrument part. For a conceptual overview, see Styles.

To obtain a style from a segment, use the IDirectMusicSegment8::GetParam method, as in the following example function, where the dwStyleIndex parameter specifies the index of the style within the segment:

HRESULT GetStyle(IDirectMusicSegment8* pSegment, DWORD dwStyleIndex, 
                 IDirectMusicStyle8** ppStyle)
  return pSegment->GetParam(GUID_IDirectMusicStyle, 0xFFFFFFFF,
                            dwStyleIndex, 0, NULL, (LPVOID*)ppStyle);

A style by itself does not contain enough information to create a segment of music at run time. For this you need two other components: a chordmap, which is a scheme of possible chord progressions, and a command track to set the groove level and embellishments as the music plays. The command track can come from a template or be generated at run time from a shape. The chordmap generally comes from a chordmap file or resource.

To create a segment with a command track based on a template, call the IDirectMusicComposer8::ComposeSegmentFromTemplate method.

To create a segment based on a shape, call the IDirectMusicComposer8::ComposeSegmentFromShape method. You supply pointers to a style and a chordmap. You also supply a rate of harmonic motion, which controls the frequency of chord changes, and a shape constant, which determines the progression of groove levels and embellishments.

See Also