CocosDenshion volume control on Windows

CocosDenshion volume control on Windows
0.0 0


I was wondering if there are any plans to fix these three identical issues:

They all involve being unable to change sound/music volume on windows.

I was wondering because this seems like a very critical feature (and it makes it very difficult to test volume related things)


Any news about this issue?
Our final target is iOS but we need this for the Music Composer
and the Sound Effects Studio (to be able to make tests on Windows).



Trying to patch SimpleAudioEngine to set volume in Windows

void MciPlayer::Volume(UINT volume)

  if (! m_hDev)

  MCIERROR MciErr ;  // error value

  MCI_DGV_SETAUDIO_PARMS  mciParams = {0};

  mciParams.dwItem = MCI_DGV_SETAUDIO_VOLUME;

  mciParams.dwValue = volume;

  MciErr = mciSendCommand (m_hDev, MCI_SETAUDIO, MCI_DGV_SETAUDIO_ITEM | MCI_DGV_SETAUDIO_VALUE, (DWORD) & mciParams);   


UINT MciPlayer::Volume () const


  if (! m_hDev)

    return 0;

  MCI_STATUS_PARMS mciParams = {0};

  mciParams.dwItem = MCI_DGV_STATUS_VOLUME;

  mciSendCommand (m_hDev, MCI_STATUS, MCI_STATUS_ITEM, (DWORD) & mciParams);

  return mciParams.dwReturn;


But it isn’t working, I’m getting an error on mciSendCommand for setting the volume. Has anyone out there solved this issue?

Setting the volume on Windows

I too am using SimpleAudioEngine because I’ve experienced glitches with the new experimental::AudioEngine. Here’s the code that worked for me:

void MciPlayer::SetVolume(float vol)
    if (! _dev)

    MCI_DGV_SETAUDIO_PARMS parms = {0};
    parms.dwCallback = reinterpret_cast<DWORD_PTR>(_wnd);
    parms.dwItem = MCI_DGV_SETAUDIO_VOLUME;
    parms.dwValue = 1000.0f * vol;
    parms.dwOver = 0;
    parms.lpstrAlgorithm = NULL;
    parms.lpstrQuality = NULL;
    if (parms.dwValue > 1000)
        parms.dwValue = 1000;

    MCIERROR err = mciSendCommand(_dev, MCI_SETAUDIO, MCI_DGV_SETAUDIO_ITEM | MCI_DGV_SETAUDIO_VALUE, reinterpret_cast<DWORD_PTR>(&parms));   

You can also use it with the shared background music:

void SimpleAudioEngine::setBackgroundMusicVolume(float volume)


I ended up starting over with DirectSound instead of MciPlayer. MciPlayer is a mess.

I couldn’t get the code from natweiss to work, but you can replace SimpleAudioEngine’s implementation with directsound and have fully, working, high performance multi-channel sound engine for Win32.

Don’t give up! I know I almost did, but it can work =)