Page 1 of 1

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

Posted: Sun Jan 23, 2011 12:56 pm
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,

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

Posted: Sun Jan 23, 2011 5:21 pm
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)

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

Posted: Sun Jan 23, 2011 6:12 pm
by marc_256
Hi Rook Zimbabwe,

I go test this...

Thanks for your answer,
Marc