none
how to adjust the Volume of Sound?

Answers

  • Hi Myime,

    Base on my understanding, you want to adjust volume of sound using waveOutSetVolume API,  if I have misunderstood you, please let me know, thanks.

     

     

    I have tried a sample of waveOutSetVolume , it works fine. Code is sample.

     

    Code Snippet

       waveOutSetVolume(0, 0);

     

     

    The simple code can set the first audio off.

    Other value related to audio control

    Code Snippet

    OFF = 0,

    LOW = 858993459,

    NORMAL = 1717986918,

    MEDIUM = -1717986919,

    HIGH = -858993460,

    VERY_HIGH = -1

     

     

     

     

    Best regards,

    Guang-Ming Bian - MSFT

    Monday, September 24, 2007 10:06 AM
    Moderator

All replies

  • Hi Myime,

    Base on my understanding, you want to adjust volume of sound using waveOutSetVolume API,  if I have misunderstood you, please let me know, thanks.

     

     

    I have tried a sample of waveOutSetVolume , it works fine. Code is sample.

     

    Code Snippet

       waveOutSetVolume(0, 0);

     

     

    The simple code can set the first audio off.

    Other value related to audio control

    Code Snippet

    OFF = 0,

    LOW = 858993459,

    NORMAL = 1717986918,

    MEDIUM = -1717986919,

    HIGH = -858993460,

    VERY_HIGH = -1

     

     

     

     

    Best regards,

    Guang-Ming Bian - MSFT

    Monday, September 24, 2007 10:06 AM
    Moderator
  • Thanks, Guang-Ming Bian.

    yes, i want to use waveOutSetVolume to control adjust volume of sound which is using PlaySound to play wav files.

    but i am not sure whether it can do that.

    Now i will try it. but i can understand hot to using that?

    Does i just  use waveOutSetVolume to set Volume, before call PlaySound?

    not do as the http://www.pocketpcdn.com/articles/soundvolume.html said?

    before,

    WAVEFORMATEX wf;
    wf.wFormatTag = WAVE_FORMAT_PCM;
    wf.nChannels = 1;
    wf.nSamplesPerSec = 8000 * 1000;
    wf.wBitsPerSample = 8;
    wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
    wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
    wf.cbSize = 0;

    HWAVEOUT hwo;
    for (UINT id = 0; id < waveOutGetNumDevs(); id++) {
    if (waveOutOpen(&hwo, id, &wf, 0, 0, CALLBACK_NULL)
                        == MMSYSERR_NOERROR)
                    {
    waveOutSetVolume(hwo, dwVolume);
    // waveOutClose(hwo);
    break;
    }
    }

     

    then call PlaySound

    last  waveOutClose(hwo);

     

    right?

    Monday, September 24, 2007 12:32 PM
  • Hi Myime,

    waveOutSetVolume method adjust system volumne, not only your application. So you can call the API any time. You can only use waveOutSetVolume mehtod to adjust the system volumne.

     

    waveOutSetVolume(0,0) will set the volumne off , regardless whether you call PlaySound method.

     

     

     

    Best regards,

    Guang-Ming Bian - MSFT

    Tuesday, September 25, 2007 1:52 AM
    Moderator
  • Hi, Guang-Ming Bian.

    Thank you  very much.

    now , it can work well.

    Tuesday, September 25, 2007 7:38 AM