Microsoft DirectX 9.0 SDK Update (Summer 2004) |
Playing Sounds on Audiopaths
If your application has created a default audiopath in the call to IDirectMusicPerformance8::InitAudio, you can play a segment on this path by using IDirectMusicPerformance8::PlaySegment. You can also play a segment on the default path by passing NULL in the pAudioPath parameter of IDirectMusicPerformance8::PlaySegmentEx.
If there is no default audiopath, or if you want to play a segment on another path, you must use PlaySegmentEx rather than PlaySegment. You can specify the audiopath in two ways:
- Supply a pointer in the pAudioPath parameter. Usually this is the IDirectMusicAudioPath8 interface pointer you received when the audiopath was created.
- Include DMUS_SEGF_USE_AUDIOPATH in dwFlags. This flag causes the segment to create an audiopath from a configuration embedded in the segment object.
Note An audiopath created in response to the DMUS_SEGF_USE_AUDIOPATH flag is released as soon as the segment has stopped playing. If the audiopath contains an effect such as reverberation, the effect is cut short prematurely. To prevent this from happening, the application should create the audiopath manually and release it only after a suitable delay.
Bands are not downloaded for segments played with the DMUS_SEGF_USE_AUDIOPATH flag unless automatic downloading is enabled. For more information, see Automatically Downloading Bands.
The following example function plays a segment on an embedded audiopath configuration if one is available, or on the default audiopath otherwise:
HRESULT PlayOnEmbedded(IDirectMusicPerformance8* pPerf, IDirectMusicSegment8 *pSeg)
{
IDirectMusicAudioPath8 * pPath = NULL;
IUnknown *pConfig;
HRESULT hr;
if (pSeg)
{
if (SUCCEEDED(hr = pSeg->GetAudioPathConfig(&pConfig)))
{
hr = pPerf->CreateAudioPath(pConfig, TRUE, &pPath);
pConfig->Release();
}
hr = pPerf->PlaySegmentEx(pSeg, NULL, NULL, 0, 0, NULL, NULL, pPath);
if (pPath)
{
pPath->Release();
pPath = NULL;
}
}
return hr;
}
If you have an interface to the audiopath, you can change the volume by using IDirectMusicAudioPath8::SetVolume. Unlike the global parameter GUID_PerfMasterVolume, which affects all sounds playing on the synthesizer, this method sets the volume only on the
© 2004 Microsoft Corporation. All rights reserved.