# Programmer Instrument Event C# script hangs on var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo(key, out dialogueSoundInfo);

**URL:** <https://qa.fmod.com/t/programmer-instrument-event-c-script-hangs-on-var-keyresult-fmodunity-runtimemanager-studiosystem-getsoundinfo-key-out-dialoguesoundinfo/20003>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [March 21, 2023, 9:59pm UTC](https://qa.fmod.com/t/programmer-instrument-event-c-script-hangs-on-var-keyresult-fmodunity-runtimemanager-studiosystem-getsoundinfo-key-out-dialoguesoundinfo/20003 "2023-03-21T21:59:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajportelli](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@ajportelli](https://qa.fmod.com/u/ajportelli)\
**Post date:** [March 21, 2023, 9:59pm UTC](https://qa.fmod.com/t/programmer-instrument-event-c-script-hangs-on-var-keyresult-fmodunity-runtimemanager-studiosystem-getsoundinfo-key-out-dialoguesoundinfo/20003/1 "2023-03-21T21:59:13Z")

</div>

I am having difficulty getting programmer instrument events to work. I am trying to build a relatively simple dialog system which uses the streaming asset folder and the code provided in the FMOD documentation but the whole of Unity freezes when this line is hit in the callback function:

var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo(key, out dialogueSoundInfo);

The script is the same as that taken from here for testing:  
[https://www.fmod.com/docs/2.01/unity/examples-programmer-sounds.html](https://www.fmod.com/docs/2.01/unity/examples-programmer-sounds.html)

I was wondering if there are any addition tutorials or examples out there to look at or if anyone has had the same issue?

many thanks

Anthony

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 22, 2023, 4:04am UTC](https://qa.fmod.com/t/programmer-instrument-event-c-script-hangs-on-var-keyresult-fmodunity-runtimemanager-studiosystem-getsoundinfo-key-out-dialoguesoundinfo/20003/2 "2023-03-22T04:04:26Z")

</div>

Hi,

What version of FMOD are you using?

Could you elaborate on how you use the `StreamingAssets` folder?

Programmer instruments work best for dialogue in conjunction with Audio Tables ([FMOD Studio | Dialogue and Localization](https://fmod.com/docs/2.02/studio/dialogue-and-localization.html#audio-tables))

---

<div class="post-metadata">

**Author:** ![ajportelli](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@ajportelli](https://qa.fmod.com/u/ajportelli)\
**Post date:** [March 22, 2023, 5:08pm UTC](https://qa.fmod.com/t/programmer-instrument-event-c-script-hangs-on-var-keyresult-fmodunity-runtimemanager-studiosystem-getsoundinfo-key-out-dialoguesoundinfo/20003/3 "2023-03-22T17:08:09Z")

</div>

Hi Connor,

No problem, I am using 2.02.12 64-bit.

Absolutely, as I said in my post I am using the verbatim code from the link originally posted. I have copied my mp3 assets into the streaming assets folder created by FMOD and they are selected using this block in the callback:

```
if (key.Contains("."))
                {
                    FMOD.Sound dialogueSound;
                    var soundResult = FMODUnity.RuntimeManager.CoreSystem.createSound(Application.streamingAssetsPath + "/" + key, soundMode, out dialogueSound);
                    if (soundResult == FMOD.RESULT.OK)
                    {
                        parameter.sound = dialogueSound.handle;
                        parameter.subsoundIndex = -1;
                        Marshal.StructureToPtr(parameter, parameterPtr, false);
                    }
                }
                else
                {
                    FMOD.Studio.SOUND_INFO dialogueSoundInfo;
                    var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo(key, out dialogueSoundInfo);
                    if (keyResult != FMOD.RESULT.OK)
                    {
                        break;
                    }
                    FMOD.Sound dialogueSound;
                    var soundResult = FMODUnity.RuntimeManager.CoreSystem.createSound(dialogueSoundInfo.name_or_data, soundMode | dialogueSoundInfo.mode, ref dialogueSoundInfo.exinfo, out dialogueSound);
                    if (soundResult == FMOD.RESULT.OK)
                    {
                        parameter.sound = dialogueSound.handle;
                        parameter.subsoundIndex = dialogueSoundInfo.subsoundindex;
                        Marshal.StructureToPtr(parameter, parameterPtr, false);
                    }
                }

```

I have used as a key “sound” and “sound.mp3” and in both instances Unity freezes at the these lines:

var soundResult = FMODUnity.RuntimeManager.CoreSystem.createSound(Application.streamingAssetsPath + “/” + key, soundMode, out dialogueSound);

and

var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo(key, out dialogueSoundInfo);

I originally attempted to use an audio table but had the same issues, Unity would freeze in the callback.

many thanks

AJ

---

<div class="post-metadata">

**Author:** ![ajportelli](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@ajportelli](https://qa.fmod.com/u/ajportelli)\
**Post date:** [March 22, 2023, 10:27pm UTC](https://qa.fmod.com/t/programmer-instrument-event-c-script-hangs-on-var-keyresult-fmodunity-runtimemanager-studiosystem-getsoundinfo-key-out-dialoguesoundinfo/20003/4 "2023-03-22T22:27:08Z")

</div>

So after looking around the forums more, after a few google searches I managed to find someone else who had the same issue as me using the code that is supplied.

> [@FMOD Programmer Sound Freeze on Unity](https://qa.fmod.com/t/fmod-programmer-sound-freeze-on-unity/19911):
>
> Hello, Playing Programmer Sound is freezing Unity. All the other non-Programmer Sound has been working perfectly for the last 3 years development on this project… Once I play few programmer sound as each dialogue line plays, it freezes the editor without any error message. It happens roughly about 7~13 Programmer Sound plays later - it’s pretty random at this point. I am on: Unity 2020.3.38f1 FMOD 2.01.11 Below is my code to use Programmer Sound wichi is based on [https://www.fmod.com/docs…](https://www.fmod.com/docs/2.01/unity/examples-programmer-sounds.html)

This solution appears to have solved the unity hanging but I do have a CHANNEL\_STOLEN error come up which I will continue to investigate.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 24, 2023, 1:43am UTC](https://qa.fmod.com/t/programmer-instrument-event-c-script-hangs-on-var-keyresult-fmodunity-runtimemanager-studiosystem-getsoundinfo-key-out-dialoguesoundinfo/20003/5 "2023-03-24T01:43:16Z")

</div>

Hi,

Thank you for linking to the solution.

The `Channel_STOLEN` Error means “The specified [Channel](https://fmod.com/docs/2.02/api/core-api-channel.html) has been reused to play another [Sound](https://fmod.com/docs/2.02/api/core-api-sound.html).” Error explanations can be found under [FMOD API | Core API Reference - Common](https://fmod.com/docs/2.02/api/core-api-common.html#fmod_result:~:text=FMOD_ERR_CHANNEL_STOLEN). This may be caused by the `Programmer Instrument` playing their sound on the same channel multiple times.

Hope this helps!
