Microsoft DirectX 9.0 |
Because a WAV sound has no tempo, the loader cannot calculate the music-time length of a segment loaded from a WAV file or resource, and it always sets the length to 1 tick. In consequence, you cannot cue another segment to play immediately after a WAV segment by using the DMUS_SEGF_QUEUE flag. A further limitation is that you must play the WAV segment from the beginning, because IDirectMusicSegment8::SetStartPoint fails with any parameter greater than the known music-time length of the segment.
To overcome these limitations, you must set the length of the segment to a music-time value equivalent to the clock-time length of the sound. The length of the sound can be calculated from the WAV chunk headers; the DirectX SDK includes sample code to do this. The following sample function sets the length of a WAV segment whose length is known:
HRESULT SetWAVLength(IDirectMusicSegment8* pSeg,
DWORD tempo, // In beats per minute.
float wavLength) // In seconds.
{
if (pSeg)
{
MUSIC_TIME mt;
mt = (wavLength * DMUS_PPQ * tempo) / 60;
return pSeg->SetLength(mt);
}
else return E_POINTER;
}
See Also