DirectMusic Sound Volume

Hi - I'm just trying to get my head around DirectMusic at the moment. I have the following script:

m_pPerformance -> PlaySegmentEx( m_pSegment[1/*i*/], NULL, NULL, DMUS_SEGF_SECONDARY | DMUS_SEGF_REFTIME,rtNow+1250000, NULL, NULL, m_pAudioPath[1/*i*/] );

... which will play a segment of sound. However, I'm trying to figure out how to control the volume for this sound when played via a value that is given from a slider in the dialog box. What is the best function to use in this case?

Hope this makes sense! Many thanks in advance

Who is Participating?
davebytesConnect With a Mentor Commented:
If you want minimal control, you can just do:

int fms = 0; // ms to fade to new volume
int hdb = -100; // hundredths of a decibel in volume, -9600 -> 0
m_pAudioPath[1]->SetVolume(hdb, dms);

Alternately, to completely control the buffer, get the DSound interface and set the volume there (ensures no channel events play with the volume outside of your control):

IDirectSoundBuffer8* pDSB = NULL;
                              GUID_NULL, 0, IID_IDirectSoundBuffer,
                              (LPVOID*) &pDSB);
if (pDSB)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.