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

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

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

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)

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

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.

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.

Hi,

Thank you for linking to the solution.

The Channel_STOLEN Error means “The specified Channel has been reused to play another Sound.” Error explanations can be found under FMOD API | Core API Reference - Common. This may be caused by the Programmer Instrument playing their sound on the same channel multiple times.

Hope this helps!