3Dsound problems

Blitz3D Forums/Blitz3D Programming/3Dsound problems

Bob13(Posted 2005) [#1]
Hi there...
is it possible to delete a channel created with emitsound() or to stop this channel ?

camera=CreateCamera()
CreateListener(camera)

sound=load3dsound("test.wav")
loopsound sound
Ch_sound = emitsound(sound,cube)

... and now delete or stop Ch_sound


John Blackledge(Posted 2005) [#2]
Press F1 for the Help file.
Select 2D - Category.
Click Sound/Music.

You want to be looking at all the Channel commands.

Yes, I know... the 3Dsound channel controllers are in the 2D section.(?)


jfk EO-11110(Posted 2005) [#3]
Ch_sound is the channel handle (if memory serves :) ), so yes, simpy say StopChannel Ch_sound ...


Bob13(Posted 2005) [#4]
Thanks for your help,

But in fact the problem I have is :

********* StopChannel works well

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()

cube=CreateCube()
PositionEntity cube,0,0,3

CreateListener(camera)

Intro=Load3DSound("intro.mp3")
LoopSound(Intro)
CH_Sound=EmitSound(Intro,cube)

While Not KeyDown( 1 )

If KeyDown(16) Then
StopChannel(CH_Sound)
EndIf

RenderWorld
Flip

Wend

End


********* StopChannel doesn't work

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()

cube=CreateCube()
PositionEntity cube,0,0,3

CreateListener(camera)

Intro=Load3DSound("intro.mp3")
LoopSound(Intro)

While Not KeyDown( 1 )

If KeyDown(30) Then
CH_Sound=EmitSound(Intro,cube)
EndIf

If KeyDown(16) Then
StopChannel(CH_Sound)
EndIf

RenderWorld
Flip

Wend

End


John Blackledge(Posted 2005) [#5]
You should be doing:
Graphics3D 640,480
SetBuffer BackBuffer()
camera=CreateCamera()
cube=CreateCube()
PositionEntity cube,0,0,3
CreateListener(camera)
Intro=Load3DSound("ExcuseMe.wav")
LoopSound(Intro)
CH_Sound=EmitSound(Intro,cube)

While Not KeyDown( 1 )
If KeyDown(30) ; A
	StopChannel(CH_Sound) ' *******
	CH_Sound=EmitSound(Intro,cube)
EndIf
If KeyDown(16) ; Q
	StopChannel(CH_Sound)
EndIf
RenderWorld
Flip
Wend
End 

Always use StopChannel() before EnitSound() otherwise a new instance is created.
Also you should be liberally sprinkling your code with ChannelPlaying() queries.


Bob13(Posted 2005) [#6]
Ok, it works well, thanks John and Jfk for your help !