0
0

Im coding a little layer between fmod and my engine to make it even easier to use (if thats possible).

Im just wondering in which order you should be calling
FSOUND_3D_SetAttributes and FSOUND_PlaySound

To me, it makes sense to do play first since it returns the channel like this

Play(int p_soundId, CVector3 p_position)
{
int channel= FSOUND_PlaySound…..
FSOUND_3D_SetAttributes(channel, position etc….
}

Also, I was wondering, is it a good idea to keep track of exactly what sound is playing on what channel for simple sound effects? (usually 2-3 secs max)

Thanks!

  • You must to post comments
0
0

Yep, FSOUND_PlaySound() first and then FSOUND_3D_SetAttributes().

You only need to keep track of what sound is playing on what channel if you want to do any channel operations later on (i.e. FSOUND_SetVolume, FSOUND_3D_SetAttributes, any API call which takes a channel handle) If you don’t need to do any channel operations later on then you don’t need to keep track of the channel handle.

  • You must to post comments
0
0

Hello,

On the subject of channels, I have the following code which plays a sound:

[code:3mlgxydy]
void SoundSample::Play()
{
if (!FSOUND_IsPlaying(channel))
{
channel = FSOUND_PlaySoundEx(FSOUND_FREE, sampleInstance, NULL, true);

    FSOUND_SetVolume(channel, vol);
    FSOUND_SetPriority(channel, prio);
    FSOUND_SetPaused(channel, false);
}

}
[/code:3mlgxydy]

Basically, I am recording the channel that one of my soundsamples uses to play on (i.e. channel = FSOUND_PlaySoundEx), so that I can check to see whether I have already set that sample to play (i.e. FSOUND_IsPlaying(channel) ). I am using a mouse click to play a sound, so I dont want the player to click mulitple times and therefore inadvertantly play the sound over itself mulitple times.

However, because I am using FSOUND_FREE, which chooses a free channel to play in, I have a feeling that there is a logic bug in my code.
I am checking to see if the channel is playing already, but FSOUND_FREE may choose a different channel next time I call this method. So, FSOUND_IsPlaying(channel) could report back incorrectly, because that channel it played on last time may be different…

Has anyone else come across a similar problem?

  • You must to post comments
0
0

Great, thanks Brett…I thought as much.

If I did like how you suggest, would I not run off channels at some point?

If I was to do:
[code:33rddijo]channel = FSOUND_FREE;[/code:33rddijo]
as you suggest, would this automatically allocate the returned channel as now being taken i.e. no longer free?

How would I free up this channel, say if I no longer need that sound sample to play, and I would like the channel to be available for another sound sample? You see, originally I thought that a channel was not free if a sound is playing on it, then when the sound has completed it’s playing loop, the channel becomes free again.

  • You must to post comments
0
0

A channel is only in use for as long as something is playing on it. The minute the sample/stream stops, the channel is free again.

  • You must to post comments
0
0

OK great, I think Ive got it now. Thanks 😉

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.