0
0

I’m pretty new to using FMOD but I’m fairly experienced with C++. I got the system working and it seems to do fine but I have a problem with channel groups. It seems to me that the problem is, I can’t add a channel to a channel group because the channel is 0xcdcdcdcd at the time that I try to add it. I can’t find any init functions for the channel and I can’t call new on the channel. Setting the channels to NULL doesn’t help it. Here’s my code…

[code:2xzmj2d9]
FMOD_RESULT result;

FMOD::System *pfmSystem = 0;
FMOD::System_Create(&pfmSystem);
result = pfmSystem->init(100, FMOD_INIT_NORMAL, 0);

FMOD::Channel *pfmChannels[5];

FMOD::ChannelGroup *group;

result = pfmSystem->createChannelGroup("Group", &group);

for(int i=0;i<5;i++)
   {
            pfmChannels[0] = 0;

// THE PROBLEM IS HERE: result = FMOD_ERR_INVALID_HANDLE
result = pfmChannels[0]->setChannelGroup(group);
}
//result = group->setVolume(…);
//group->setMute(…); // etc.
[/code:2xzmj2d9]

As you might be able to tell, this is taken almost verbatim from the ppt slide that shows how to setup a channel group. The result is FMOD_ERR_INVALID_HANDLE. Any suggestions?

Thanks! 😀

edit:

Okay, I set it up so that it will play a sound on that channel first because I noticed that after the channel plays a sound, it no longer points to a 0xcccccccc memory address. After doing this, and then attempting to assign the channel to a channel group, it works. There has got to be a way other than playing a sound to initialize the channel.

  • You must to post comments
0
0

OK, first, I recommend you use the pined topic code to initialise the system. It will save you heartaches.

For the grouping, you can only set the channel to a group after FMOD created it for you.

I suggest you make a wrapper function arround create sound to return you a sound object instance

and another wrapper arround play sound to start the sound and set it to the group you want

sound = sound_add("thefile.mid");

channel = sound_play(sound,group);

in sound_play, you start the sound and set the channel to the appropriate group before returning the channel.

  • You must to post comments
0
0

You’re using an uninitalized pointer or null pointer to call a c++ object function, wouldn’t that seem strange to you?

You have to first get a channel handle by calling System::playSound.

Check one of the 35 or so examples in the sdk you’ll find out quickly how to use the api to do basic things like play a sound.

  • You must to post comments
0
0

icurrd12b42 – What’s this pined topic code?

[quote:20eup7bi] You’re using an uninitalized pointer or null pointer to call a c++ object function, wouldn’t that seem strange to you? [/quote:20eup7bi]

Yes, it does seem strange to me. It seems strange to me that there is no initialization function for the channels. It also seems strange to me that the way that the channels are initialized is from telling the system to play a sound on that uninitialized channel. That’s pretty much why I started this topic. Thanks for the tip, I’ll check the SDK for examples.

The way that makes sense to me is, knowing how many channels I might need, initializing that many channels, and then setting them up into a group, but, whatever. :)

Thanks for the help, I think I’m on the right track now.

  • You must to post comments
0
0

[quote="bmantzey":212emvwj]icurrd12b42 – What’s this pined topic code?
[/quote:212emvwj]

It used to be pinned

http://52.88.2.202/forum/viewtopic.php … stemcreate

[quote:212emvwj]
[quote:212emvwj] You’re using an uninitalized pointer or null pointer to call a c++ object function, wouldn’t that seem strange to you? [/quote:212emvwj]

Yes, it does seem strange to me. It seems strange to me that there is no initialization function for the channels. It also seems strange to me that the way that the channels are initialized is from telling the system to play a sound on that uninitialized channel. That’s pretty much why I started this topic. Thanks for the tip, I’ll check the SDK for examples.

The way that makes sense to me is, knowing how many channels I might need, initializing that many channels, and then setting them up into a group, but, whatever. :)

Thanks for the help, I think I’m on the right track now.[/quote:212emvwj]

And look at the Getting Started in the tutorial section of the help file.

It’s best you make wrapper functions like I mentioned. Or the system may drive you nuts a little.

I’m trying to explain the concept in plain english so pardon me if it’s not 100% accurate.

FMOD’s SoundPlay inititalizes the channel for you. Passing the reference to the pointer allows FMOD to set that pointer to the address of the system/sound/channel/group it internaly creates and sets up for you.

A little different than performing the new yourself… But’s it’s the same thing.

The long version, if it existed would look like this, I gather

System *sys = new System(100)
Group *g = new Group(sys)
Sound *s = new Sound(filename, sys);
Channel *c = new Channel(s,group,sys);

Think of a channel as a "playing sound instance". In your game, you know how many sound resources you will use but you don’t know how many sounds will actually play during the course of the game. How many flying bullet sounds will play at one time? You don’t know… So FMOD takes care of that internally with the channel management system.

That is why a new channel is created every time you play a sound. And old stail channels are reused if you go beyond the maximum number of channels specified.

As for how many channels you might need, that’s defined by you in the System::init call.

Because of the channel stealing system, it makes no sense for you to have access and hold on to a channel for a long period of time. Another playing sound will later be hooked to it. That new sound may also then need to belong to another group… Say a channel was playing a bullet sound and is ready to be reused. The old bullet sound was in the effects group. Now the channel is asked to play menu music which belongs in the master group…

You see now why you have to set the group after you start the sound… In the associated channel returned by soundPlay

I like to load all my sounds and tell them what group they will belong too when they get played. I use UserInfo for that.

I set up a structure and stuff it in the sound using user info. After I start the sound, I peek at the structure (getUserInfo), get the group it will be in and set the channel to the group.

But that’s just me. Others may use the same sound in many groups for many reasons… Again, that is why the channel is set to the group after the "playing sound instance" is associated with a channel.

I think that enough for today 😉

  • You must to post comments
0
0

A very helpful reply. Thank you very much.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.