DirectMusic Sound Volume

Posted on 2005-04-06
Last Modified: 2008-02-01
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

Question by:nickisme
    1 Comment
    LVL 17

    Accepted Solution

    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;
    m_pAudioPath->GetObjectInPath(DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER, 0,
                                  GUID_NULL, 0, IID_IDirectSoundBuffer,
                                  (LPVOID*) &pDSB);
    if (pDSB)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
    Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now