# userData problem when upgrade from fmodex

**URL:** <https://qa.fmod.com/t/userdata-problem-when-upgrade-from-fmodex/12762>\
**Category:** FMOD Studio\
**Created:** [October 21, 2016, 10:11am UTC](https://qa.fmod.com/t/userdata-problem-when-upgrade-from-fmodex/12762 "2016-10-21T10:11:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![notabdc](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@notabdc](https://qa.fmod.com/u/notabdc)\
**Post date:** [October 21, 2016, 10:11am UTC](https://qa.fmod.com/t/userdata-problem-when-upgrade-from-fmodex/12762/1 "2016-10-21T10:11:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [October 23, 2016, 11:31pm UTC](https://qa.fmod.com/t/userdata-problem-when-upgrade-from-fmodex/12762/2 "2016-10-23T23:31:37Z")

</div>

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.
