sound - can someone explain why this doesn't work

BlitzMax Forums/BlitzMax Beginners Area/sound - can someone explain why this doesn't work

Dax Trajero(Posted 2006) [#1]
sound=LoadSound("audio/idle.wav")
channel=CueSound(sound)


While Not KeyHit(KEY_ESCAPE)

If ChannelPlaying (channel)=False Then

ResumeChannel channel

End If

Wend


Warren(Posted 2006) [#2]
*sigh*

Can you define "doesn't work"?


Dax Trajero(Posted 2006) [#3]
no sound


Yan(Posted 2006) [#4]
Cos you're doing it wrong. ;op
Strict

Local bmxPath$ = getenv_("BMXPATH")

Local snd:TSound = LoadSound(bmxPath$ + "/samples/hitoro/sounds/gameover.ogg")

Graphics 800, 600, 0

Local chn:TChannel = PlaySound(snd)
Repeat
	If Not(ChannelPlaying(chn))
		StopChannel(chn)
		chn = PlaySound(snd)
	EndIf
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

End
...or...
Strict

Local bmxPath$ = getenv_("BMXPATH")

Local snd:TSound = LoadSound(bmxPath$ + "/samples/hitoro/sounds/gameover.ogg")

Graphics 800, 600, 0

Local chn:TChannel = PlaySound(snd)
Repeat
	If Not(ChannelPlaying(chn))
		PlaySound(snd, chn)
	EndIf
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

End
...or...
Strict

Local bmxPath$ = getenv_("BMXPATH")

Local snd:TSound = LoadSound(bmxPath$ + "/samples/hitoro/sounds/gameover.ogg")
Local chn:TChannel = AllocChannel()

Graphics 800, 600, 0

PlaySound(snd, chn)
Repeat
	If Not(ChannelPlaying(chn)) Then PlaySound(snd, chn)
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

End
...or...
Strict

Local bmxPath$ = getenv_("BMXPATH")

Local snd:TSound = LoadSound(bmxPath$ + "/samples/hitoro/sounds/gameover.ogg")
Local chn:TChannel = AllocChannel()

CueSound(snd, chn)
SetChannelVolume(chn, Rnd(0, 1))
SetChannelPan(chn, Rnd(0, 2) - 1)

Graphics 800, 600, 0

ResumeChannel(chn)
Repeat
	If Not(ChannelPlaying(chn))
		CueSound(snd, chn)
		SetChannelVolume(chn, Rnd(0, 1))
		SetChannelPan(chn, Rnd(0, 2) - 1)
		ResumeChannel(chn)
	EndIf
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

End
...and all the other possible combinations, but you get the idea... :o)


Dax Trajero(Posted 2006) [#5]
Thanks Ian


boomboom(Posted 2008) [#6]
Hi, I was doing it a similer way to Dax. Where in the documentation does it say todo it Yan's way (aka the right way)?


plash(Posted 2008) [#7]
Where in the documentation does it say todo it Yan's way (aka the right way)?
Since when were the docs perfect?


skidracer(Posted 2008) [#8]
If ChannelPlaying is returning true on cued sounds then that is a bug in whatever driver on whichever platform Dax is using.


boomboom(Posted 2008) [#9]
lol, this probably sounded more rude than i ment to be (getting late) I was just curious as to where in the docs this information can be found. I found it in the end. It would be nice if TChannel and TSound help (what u go to when u press f1) had a link back to the general sound library help file.