| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| talkerzero Grandmaster Cheater
 
 ![]() Reputation: 1 
 Joined: 24 Jul 2008
 Posts: 560
 Location: California
 
 | 
			
				|  Posted: Mon Feb 09, 2009 3:21 pm    Post subject: [C++] Is there a way to change the speaker volume? |   |  
				| 
 |  
				| Regardless of how much coding must be done, is it possible to change the speaker volume with C++? Drivers, etc.? 
 If so, example please?
   |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Noz3001 I'm a spammer
 
  Reputation: 26 
 Joined: 29 May 2006
 Posts: 6220
 Location: /dev/null
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| talkerzero Grandmaster Cheater
 
 ![]() Reputation: 1 
 Joined: 24 Jul 2008
 Posts: 560
 Location: California
 
 | 
			
				|  Posted: Mon Feb 09, 2009 4:01 pm    Post subject: |   |  
				| 
 |  
				| I have XP, so.. yeah.   
 But using noz3001's reply, here's the test code I'm using:
 
 
  	  | Code: |  	  | #include <windows.h> 
 int main(){
 for(;;){
 while(!GetAsyncKeyState(VK_F12))
 Sleep(100);
 while(GetAsyncKeyState(VK_F12))
 Sleep(10);
 waveOutSetVolume(0, 0);
 }
 }
 | 
 
 I'm getting this error:
 
  	  | Code: |  	  | main.obj : error LNK2019: unresolved external symbol __imp__waveOutSetVolume@8 referenced in function _main | 
 
 Help?
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| talkerzero Grandmaster Cheater
 
 ![]() Reputation: 1 
 Joined: 24 Jul 2008
 Posts: 560
 Location: California
 
 | 
			
				|  Posted: Mon Feb 09, 2009 6:48 pm    Post subject: |   |  
				| 
 |  
				| Thanks, got it working. Now I want to play a sound. I'm using.. 
 
  	  | Code: |  	  | PlaySound("beat.wav", 0, SND_FILENAME | SND_LOOP); | 
 
 It keeps returning 0 and nothing happens. "beat.wav" exists in the same directory as my program. Help?
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| dnsi0 I post too much
 
 ![]() Reputation: 0 
 Joined: 04 Jan 2007
 Posts: 2674
 
 
 | 
			
				|  Posted: Mon Feb 09, 2009 6:50 pm    Post subject: |   |  
				| 
 |  
				|  	  | talker0 wrote: |  	  | Thanks, got it working. Now I want to play a sound. I'm using.. 
 
  	  | Code: |  	  | PlaySound("beat.wav", 0, SND_FILENAME | SND_LOOP); | 
 
 It keeps returning 0 and nothing happens. "beat.wav" exists in the same directory as my program. Help?
 | 
 
 Try adding the full path and see if it works.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| lurc Grandmaster Cheater Supreme
 
  Reputation: 2 
 Joined: 13 Nov 2006
 Posts: 1900
 
 
 | 
			
				|  Posted: Mon Feb 09, 2009 6:54 pm    Post subject: |   |  
				| 
 |  
				| How are you running your program. 
 Because if you run via F5 (Run&Debug) I believe it uses the directory where all the source files are located. Full path would work or put the file in both the Debug/Release folder and source folder to see if it works then.
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| talkerzero Grandmaster Cheater
 
 ![]() Reputation: 1 
 Joined: 24 Jul 2008
 Posts: 560
 Location: California
 
 | 
			
				|  Posted: Mon Feb 09, 2009 6:58 pm    Post subject: |   |  
				| 
 |  
				| I've changed my settings to build the program on my desktop. I'm building it then running it manually. My WAV file is also on my desktop. I read somewhere that I need to import (or something like that) winmm.lib. Help? I already have #pragma comment(lib, "winmm.lib") at the top, and typed in "winmm.lib" in Project Properties >> Linker >> Input >> Additional Dependencies. PlaySound still returning 0. Any ideas? |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| talkerzero Grandmaster Cheater
 
 ![]() Reputation: 1 
 Joined: 24 Jul 2008
 Posts: 560
 Location: California
 
 | 
			
				|  Posted: Mon Feb 09, 2009 7:06 pm    Post subject: |   |  
				| 
 |  
				| Hmm.. interesting. Now it's returning 1, but nothing's playing. My speaker's on, I've also set the volume back at 0xFFFF.   |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| talkerzero Grandmaster Cheater
 
 ![]() Reputation: 1 
 Joined: 24 Jul 2008
 Posts: 560
 Location: California
 
 | 
			
				|  Posted: Mon Feb 09, 2009 7:20 pm    Post subject: |   |  
				| 
 |  
				| I think it's ultimately a problem with my computer and sound.. I can never listen to the sound on YouTube either. Ever since a couple years ago.. something happened.   |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| BanMe Master Cheater
 
 ![]() Reputation: 0 
 Joined: 29 Nov 2005
 Posts: 375
 Location: Farmington NH, USA
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |