# Marhsalling to Channel after getting callback

**URL:** <https://qa.fmod.com/t/marhsalling-to-channel-after-getting-callback/17782>\
**Category:** Unity\
**Created:** [October 12, 2021, 1:16am UTC](https://qa.fmod.com/t/marhsalling-to-channel-after-getting-callback/17782 "2021-10-12T01:16:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![john.bess](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@john.bess](https://qa.fmod.com/u/john.bess)\
**Post date:** [October 12, 2021, 1:16am UTC](https://qa.fmod.com/t/marhsalling-to-channel-after-getting-callback/17782/1 "2021-10-12T01:16:26Z")

</div>

Im trying to handle a callback in unity from an arbitrary sound ending using the programmer sounds API… it looks something like this:

FMODUnity.RuntimeManager.CoreSystem.createSound(Application.streamingAssetsPath + “/” + eventId, soundMode, out FMOD.Sound fmodSound);

```
    FMODUnity.RuntimeManager.CoreSystem.playSound(fmodSound, musicChannelGroup, false, out soundChannel);

    soundChannel.setCallback(channelResult);

```

With channel result looking something like this:

private RESULT channelResult(IntPtr channelcontrol, CHANNELCONTROL\_TYPE controltype, CHANNELCONTROL\_CALLBACK\_TYPE callbacktype, IntPtr commanddata1, IntPtr commanddata2)  
{  
Channel passedChannel = Marshal.PtrToStructure(channelcontrol);  
return RESULT.OK;  
}

However, it crashes unity and when I check the logs it looks like it’s throwing an NRE.

My question is, are there any examples of the correct way to recieve/handle the callback from a channel finishing a sound in C#?

---

<div class="post-metadata">

**Author:** ![john.bess](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@john.bess](https://qa.fmod.com/u/john.bess)\
**Post date:** [October 13, 2021, 9:11pm UTC](https://qa.fmod.com/t/marhsalling-to-channel-after-getting-callback/17782/2 "2021-10-13T21:11:13Z")

</div>

After a lot of digging I ended up finding my answers via the Programmer Sounds example, documentation and other forum posts. Long story short I was doing things the wrong way…
