PlaySound and CueSound confusion

BlitzMax Forums/BlitzMax Programming/PlaySound and CueSound confusion

GfK(Posted 2008) [#1]
Just reading up on audio stuff since I haven't touched it in about a year or so.

What's the gig with these two commands? From the docs:

Function PlaySound:TChannel( sound:TSound,channel:TChannel=Null )


Function CueSound:TChannel( sound:TSound,channel:TChannel=Null )


Both functions accept a tChannel parameter, so you can specify a particular channel (created with AllocChannel()) to play through. Both return a tChannel object, so you can specify a particular channel (created with AllocChannel()) to play through.

Is this simply two different ways of achieving the same end result? OR am I missing the point of having a channel parameter *and* having a channel object returned from either function?


Brucey(Posted 2008) [#2]
Cue sound starts paused. Play sound plays immediately.

I'd guess that the channel returned would be the same as the one passed in, otherwise you get a new channel object.


Yan(Posted 2008) [#3]
It's just a convenience/backwards compatibility feature, AFAIK.

If your already passing a channel in, you'd obviously just ignore the return value.


Is this simply two different ways of achieving the same end result? OR am I missing the point of having a channel parameter *and* having a channel object returned from either function?
I think you're I missing the point of having an *optional* channel parameter. ;o)


GfK(Posted 2008) [#4]
Is there any way to read channel properties? Specifically, panning and volume?


plash(Posted 2008) [#5]
Not by default.. The types in brl.audio gets extended by audio drivers, if you were using the OpenAL library you could get the values by using the standard library functions:


BUT it won't work unless you modify openalaudio so that TOpenALSource is public :(


Grey Alien(Posted 2008) [#6]
I use CueSound to set up a sound and then tweak other params before calling ResumeSound to set it going.


plash(Posted 2008) [#7]
You could also wrap TChannel in a separate type to save the variables when pan and volume is set.

I use CueSound to set up a sound and then tweak other params before calling ResumeSound to set it going.
Yep, here is some code that I used previously when messing around with audio (slightly different method):

Global sfx_music:TSound = LoadSound("int01.ogg", SOUND_LOOP)
Assert sfx_music, "Failed to load 'int01.ogg'"

Global ch_current:TChannel = AllocChannel()
CueSound(sfx_music, ch_current)
ResumeChannel(ch_current)



GfK(Posted 2008) [#8]
Wrapping tChannel isn't a bad idea, I'll look into that tomorrow.

Spent so much time fannying about because of this today, I can't be bothered coding any more tonight.


Grey Alien(Posted 2008) [#9]
Plus if you wrap TChannel (or TSound) you can have special play functions you call with pan and volume params so playing sounds is reduced to a single command. Then you might want to consider a Channel Array and also a Sound Triggering system and possibly an Ambient Sound system too. I have these :-)