Sound problems ... in my first game ...

Advanced game related topics
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Sound problems ... in my first game ...

Post by marc_256 »

Hi all,

For my first 2D game I used some sounds and .wav background music.
When I start the game the music plays well.
When the game is over, the sound goes on and on...
Only if I quit the game the sound stop ... ???
Windows XP Home SP2


1) First I INITSOUND:

Code: Select all

	If InitSound() = 0
		MessageRequester("Error", "Can't open DirectX 7 or no sound card is available",  0)
		Goto einde
	Else
		Goto Start_Of_Game
	EndIf
2) I Catch the sound from memory

Code: Select all

 	CatchSound(Sound_Elektro_Num, ?Sound_Elektro)
3) I play the sound

Code: Select all

	PlaySound(Sound_Elektro_Num, #PB_Sound_MultiChannel | #PB_Sound_Loop, 50)
	SoundPan(Sound_Elektro_Num, 0) 
the game logic
I play the game ...

4) When 'GAME OVER' ... I Stop the sound... !!!
The sound do not stop at all ...
I used (a)

Code: Select all

	StopSound(Sound_Elektro_Num)
and I used (b)

Code: Select all

	StopSound(-1) = stop all playing sounds
PS: The game can be found here ... "My first game"
http://www.marc-systems.be/pvg-3dstudio ... me_001.exe


I use on this computer:
- WIN XP Home (32 bits) (sp2)
- AMD Athlon XP-M 2400+ at 1.8 GHz with 1GB RAM
- GPU ATI-RADEON 9800 PRO with 128MB ram
- SOUND = C-Media AC97 Audio Device
- DIRECTX = DirectX 9.0c installed
- PURE BASIC = PB 4.51 RC 2
- MOUSE = IKARI steel serie laser mouse (USB)
- anti virus = NOD32


Thanks,
marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Sound problems ... in my first game ...

Post by Rook Zimbabwe »

try:

StopSound(Sound_Elektro_Num,-1)

and what channel did you start the sound on? You may have to squelch that channel... when you turned the sound on as multichannel you were assigned a value for that channel...
PlaySound(Sound_Elektro_Num, #PB_Sound_MultiChannel | #PB_Sound_Loop, 50)
try

Code: Select all

CHelektro = PlaySound(Sound_Elektro_Num, #PB_Sound_MultiChannel | #PB_Sound_Loop, 50)

;then you could try to stop it with 

StopSound(Sound_Elektro_Num,CHelektro)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Sound problems ... in my first game ...

Post by marc_256 »

Hi Rook Zimbabwe,

I go test this...

Thanks for your answer,
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
Post Reply