sound - can someone explain why this doesn't work

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

sound=LoadSound("audio/idle.wav")
channel=CueSound(sound)


While Not KeyHit(KEY_ESCAPE)

If ChannelPlaying (channel)=False Then

ResumeChannel channel

End If

Wend

*sigh*

Can you define "doesn't work"?

no sound

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)

Thanks Ian

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)?

Where in the documentation does it say todo it Yan's way (aka the right way)?
Since when were the docs perfect?

If ChannelPlaying is returning true on cued sounds then that is a bug in whatever driver on whichever platform Dax is using.

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.