I have just started using fmod, I am building a game that will use the musicsystem extensively.
I am wondering if it is possible to get the channels that are in the ‘music’ category. I was able to get a ChannelGroup but it is reporting that there are 0 channels in it and I am unable to retrieve any individual channels.
- clayrab asked 8 years ago
Yes, Peter, now that I’ve checked, I do see that there is 1 group within the group, I will dig around in there.
I need access to the channels in order to get timing information, I would like to know the current position in each segment in order to synchronize it with animations. I will also need to get the sound length, if that is possible… If not, I can work around it. Optimally, I would have liked to be able to get all of this information directly from the MusicSystem API along with time signature and bpm.
It seems that I am unable to use the channels I retrieve in this group. I am simply crawling down the tree of ChannelGroups and looking for channels.
Am I doing something wrong? I receive this message whenever I call a method on the channel I find:
[quote:26gw19ld]ERR_INVALID_HANDLE – An invalid object handle was used.[/quote:26gw19ld]
Hi again Peter,
I have gone through every channelgroup under ‘music’ and under ‘master'(the only eventcategory in our fev) and have only found one channel, which gives me the error…
The music is playing… Is there anything else you can tell me?
Well it sounds like the channel you’re getting, is going invalid before you use it. It should be valid at the time you get it.
[quote:1pov4dau]Is there anything else you can tell me?[/quote:1pov4dau]
Just to give you a little background:
A FMOD::Channel* is not a pointer it’s a handle. This means it’s effectively just an unsigned int used as an identifier. When it is valid that int corresponds to a real object inside the engine. You cannot get an access violation with channels. For example:
will just return FMOD_ERR_INVALID_HANDLE.
When you use FMOD::ChannelGroup::getChannel and use an invalid index it will set your channel pointer to NULL. This is another possible cause for your INVALID_HANDLE error.
You mentioned that the music was playing when you were searching for a channel. This is very important, a channel only exists when sound is playing.
For my test I searched all the channel groups to find one with a channel and then called setPaused on that channel and there was no error.
It might be helpful to try calling FMOD::EventSystem::update some of the channel management stuff can happen in there as well.
Let me know how you go. If you’re still stuck, please post the code where you find the channel group.
Please login first to submit.