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)
- mnok asked 14 years ago
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.
On the subject of channels, I have the following code which plays a sound:
channel = FSOUND_PlaySoundEx(FSOUND_FREE, sampleInstance, NULL, true);
FSOUND_SetVolume(channel, vol); FSOUND_SetPriority(channel, prio); FSOUND_SetPaused(channel, false); }
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?
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.
Please login first to submit.