Jump to content

Sound Problems :D

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Nille

Nille

    Learning Programmer

  • Members
  • PipPipPip
  • 41 posts
Hi guys, got a bit of a problem.
I am making a program (an alarm clock :P) and i want to be able to increase the system sound volume (might be the wrong name for it but anyways) but i dont know quite how to, i found 2 pages on msdn (Microsoft developer network)
waveOutGetVolume
and
waveOutSetVolume
but i don't quite understand how to use it.
I understand that the sound is increased and decreased by setting the value of a variable.
What i don't understand is how to declare that variable and how to make the volume change as i change the variables value.

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
First you need to get the handle of the sound device you're using, then pass in the handle and volume to the waveOutSetVolume function:


HWAVEOUT  hSpeaker = NULL;


//You need to fill this structure out depending on what sound you're using

WAVEFORMATEX  soundData;


//get handle to speaker

waveOutOpen(&hSpeaker,WAVE_MAPPER,&soundData,NULL,CALLBACK_NULL);


//speaker now opened for output. Set the volume.

waveOutSetVolume(hSpeaker,/*your volume here, 0xFFFF is max*/);


//do your thing.