Microsoft DirectX 9.0

Making Band Changes Programmatically

In most cases, the band track in a loaded segment performs all necessary program changes. However, you can also do so manually if you have a band object. You must create a secondary segment by using IDirectMusicBand8::CreateSegment, and then play that segment by calling IDirectMusicPerformance8::PlaySegment or IDirectMusicPerformance8::PlaySegmentEx. Typically, you would use DMUS_SEGF_MEASURE or DMUS_SEGF_GRID in the dwFlags parameter to ensure that the band change takes effect on an appropriate boundary.

The following example function creates a segment from a band and plays it on the next measure boundary. It is presumed that the instruments have already been downloaded or that automatic downloading has been enabled.

  IDirectMusicBand8 *pBand,
  IDirectMusicPerformance8 *pPerf,
  IDirectMusicSegment *pSegment;
  HRESULT hr = pBand->CreateSegment(&pSegment);
  if (SUCCEEDED(hr))
    hr = pPerf->PlaySegment(pSegment, DMUS_SEGF_MEASURE | DMUS_SEGF_SECONDARY,
                            rfTime, NULL);
  return hr;

See Also