PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to programatically adjust overall system volume

I've been looking through the documentation and I haven't come across how to do this... I'm thinking along the lines of something like BananaPC that has the little slider for volume, and this affects every sound played on the system. I'm looking for the way to do that. Any hints? Thanks all!
Never mind, I think I found my answer:

http://www.pocketpcdn.com/qa/soundvolume.html

... in case it comes up for anyone else.
Ok, looks like I spoke too soon...

The code referenced in the link in the previous post seems to work in the emulator, but not on a real device. Anyone have any suggestions why that might be?

The game I'm using this in is written under PocketFrogPlus, but I don't suspect that's an issue, especially since a quick test program written in straight Win32 C doesn't work either with it on a real device.
Here's what I've used in the past to set the volume...

Code:

void CWave::setVolume(DWORD dwVolume)
{
WAVEFORMATEX wf;
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000;
wf.wBitsPerSample = 8;
wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
wf.cbSize = 0;

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


This sets the volume for the current application. If you want to set the volume for the entire device (not a nice thing to do) I believe all you need to do is use zero as the first argument in waveOutSetVolume.

Hope this helps...
With PocketFrogPlus ver. 0.2.4 you can change the master volume of your game with Sound::setVolume(uint32_t v). Value of v can vary from 0 (silence) to 64 (max volume) and it affects every sound played on your game. You can retrieve the current master volume value with uint32_t Sound::getVolume().
With this two function you can easily build a little slider or something else to menage the volume of your game :)

You can find an example on how to use this two functions on the blit sample included on pfp 0.2.4.
Well DUH, I'll just be over here in the corner calling myself an idiot for a while... Thanks Gersen, that did the trick perfectly! I wish I had thought to look through your extensions before posting here. Thanks a bunch! :)
de nada :D