userData problem when upgrade from fmodex

in my fmodex project, I set userdata for every channel just after fmod system is created:

g_numFmodChannels = 32;
result = g_FMOD_system->init(g_numFmodChannels, FMOD_INIT_NORMAL, extradriverdata);
for (int i = 0; i < g_numFmodChannels; i++)
{
FMOD::Channel *channel;
result = g_FMOD_system->getChannel(i, &channel);
result = channel->setUserData(&g_FModChannelDatas[i]);
}

then, get back that userdata when a sound is played:

FMOD::Channel *channel;
result = g_FMOD_system->playSound(FMOD_CHANNEL_FREE, g_musicSound, false, &channel);
result = channel->getUserData(&userData);

userData is just one of that I set in previous code.

Now I upgrade to fmod studio (low level) API 1.0. when I call:

FMOD::Channel *channel;
result = g_FMOD_system->playSound(g_musicSound, NULL, false, &channel);
result = channel->getUserData(&userData);

userData is NULL. I noticed that the channel created is not one of that got using g_FMOD_system->getChannel(i, &channel);

it seems there are some broken changes from fmodex to studio api. Please help me.

Hi,
A channel is freshly created every time you play a sound. You should be storing data either when it is played, and not by a hard coded index, or if you want userdata before the sound is played, store it in the sound.

1 Like