I have an array of channel pointers in my FMODWrapper class in my game game at the moment.
What I am doing is looping through the array of channels, calling ->isPlaying on each one and playing the next sound on a channel that is not playing.
What I want to know is, should I have an array of channels as member data or should I instantiate a channel, add it to a group, and then let the channel go out of scope?
Does FMOD manage internally all the channels that you assign to a group, making a copy of each channel you assign to the group?
Thank you for any help.
- bmantzey asked 10 years ago
I’m still confused…
Should I have FMOD::Channel* m_channels[SIZE]; as a member to my class, (which requires me to manage the channels) or…
void play(char sound)
system->playSound(/* Sound, channel, etc. */);
// And then let the channel fall out of scope and out of my control
(which means FMOD manages the channels)
Either way, I can do, I just want to know the "correct" way. I don’t want to manage a bunch of memory on my side that FMOD is managing on its side. It’s more difficult to manage the code and it doubles the memory that is being used.
you shouldnt have an array of channel pointers.
You should just be firing off oneshot sounds and forgetting them, or if you want to update a sound then the channel handle should be stored in a place relevant to the object that owns it (ie a monster, or a car), so that the object can update the sound handle (ie 3d position) with its own position etc.
Thank you Brett, I think I know what I need to do now.
After updating my system to manage the channels on its own, there has been huge improvements in the overall performance of the sounds in our game. People are impressed when they see/hear our game. Much thanks to everyone who helped.
Intanciate the channel (playSound), when it’s not playing, release it and start new sound channel. If playing a new sound from file (play list), release the old sound and add a new one.
I actually createSound for each element in my play list when the list loads/game starts for faster play when the time comes.
When the game quits, stop all your still playing chanels, and release them then release your sounds.
Store it in an array or as a member variable, does not matter. You can use the sound and channel user data to help you… I stuff the sound object into the channel user data (in a stucture) to help me…
that is the basic principle.
Once a channel is instanciated, add it to one of your groups… You will still need to manage releasing the channels and the sounds… Well, I’m pretty sure about that.
- icuurd12b42 answered 10 years ago
Please login first to submit.