# Error using Localised Audio Tables for Dialogue

**URL:** <https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [April 3, 2023, 12:26pm UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055 "2023-04-03T12:26:02Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 3, 2023, 12:26pm UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/1 "2023-04-03T12:26:02Z")

</div>

Hi there.

I’m getting the following error message when trying to play an event with a programmer event containing a localised audio table.

> [FMOD] SoundSourceInstrumentInstance::startChannelIfReady : Waveform instance in error state 18  
> UnityEngine.Debug:LogWarning (object)  
> FMODUnity.RuntimeUtils:DebugLogWarning (string) (at Assets/Plugins/FMOD/src/RuntimeUtils.cs:558)  
> FMODUnity.RuntimeManager:DEBUG\_CALLBACK (FMOD.DEBUG\_FLAGS,intptr,int,intptr,intptr) (at Assets/Plugins/FMOD/src/RuntimeManager.cs:81)

I’ve tried setting the script up according to this link:  
[https://www.fmod.com/docs/2.02/unity/examples-programmer-sounds.html](https://www.fmod.com/docs/2.02/unity/examples-programmer-sounds.html)

There must be a step I’ve missed. Thanks!

FMOD Version: 2.02.07  
Unity Version: 2021.2.7f1

---

<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:** [April 4, 2023, 1:37am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/2 "2023-04-04T01:37:48Z")

</div>

Hi,

> [@samdixonmusic](#):
>
> I’ve tried setting the script up according to this link:

Did you copy the whole example script or have you used it as a template? If so, could I see your script?

Could you also try changing `soundMode` from:

```auto
FMOD.MODE soundMode = FMOD.MODE.LOOP_NORMAL | FMOD.MODE.CREATECOMPRESSEDSAMPLE | FMOD.MODE.NONBLOCKING;

```

to

```auto
FMOD.MODE soundMode = FMOD.MODE.CREATESTREAM;

```

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 5, 2023, 9:18am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/3 "2023-04-05T09:18:45Z")

</div>

> [@Connor\_FMOD](#):
>
> Did you copy the whole example script or have you used it as a template? If so, could I see your script?

Sure. Here it is:

```auto
//--------------------------------------------------------------------
//
// This is a Unity behaviour script that demonstrates how to use
// Programmer Sounds and the Audio Table in your game code. 
//
// Programmer sounds allows the game code to receive a callback at a
// sound-designer specified time and return a sound object to the be
// played within the event.
//
// The audio table is a group of audio files compressed in a Bank that
// are not associated with any event and can be accessed by a string key.
//
// Together these two features allow for an efficient implementation of
// dialogue systems where the sound designer can build a single template 
// event and different dialogue sounds can be played through it at runtime.
//
// This script will play one of three pieces of dialog through an event
// on a key press from the player.
//
// This document assumes familiarity with Unity scripting. See
// https://unity3d.com/learn/tutorials/topics/scripting for resources
// on learning Unity scripting. 
//
// For information on using FMOD example code in your own programs, visit
// https://www.fmod.com/legal
//
//--------------------------------------------------------------------

using System;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;

class ScriptUsageProgrammerSounds : MonoBehaviour
{
    FMOD.Studio.EVENT_CALLBACK dialogueCallback;

    [SerializeField] private FMODUnity.EventReference DialogueEvent;
    [SerializeField] private string dialogueKey;

    private FMOD.Studio.EventInstance dialogueInstance;

#if UNITY_EDITOR
    void Reset()
    {
        //EventName = FMODUnity.EventReference.Find("event:/Character/Radio/Command");
    }
#endif

    void Start()
    {
        // Explicitly create the delegate object and assign it to a member so it doesn't get freed
        // by the garbage collected while it's being used
        dialogueCallback = new FMOD.Studio.EVENT_CALLBACK(DialogueEventCallback);
    }

    void PlayDialogue(string key)
    {
        dialogueInstance = FMODUnity.RuntimeManager.CreateInstance(DialogueEvent);

        // Pin the key string in memory and pass a pointer through the user data
        GCHandle stringHandle = GCHandle.Alloc(key);
        dialogueInstance.setUserData(GCHandle.ToIntPtr(stringHandle));

        dialogueInstance.setCallback(dialogueCallback);
        dialogueInstance.start();
        dialogueInstance.release();
    }

    [AOT.MonoPInvokeCallback(typeof(FMOD.Studio.EVENT_CALLBACK))]
    static FMOD.RESULT DialogueEventCallback(FMOD.Studio.EVENT_CALLBACK_TYPE type, IntPtr instancePtr, IntPtr parameterPtr)
    {
        FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);

        // Retrieve the user data
        IntPtr stringPtr;
        instance.getUserData(out stringPtr);

        // Get the string object
        GCHandle stringHandle = GCHandle.FromIntPtr(stringPtr);
        String key = stringHandle.Target as String;

        switch (type)
        {
            case FMOD.Studio.EVENT_CALLBACK_TYPE.CREATE_PROGRAMMER_SOUND:
                {
                    FMOD.MODE soundMode = FMOD.MODE.LOOP_NORMAL | FMOD.MODE.CREATECOMPRESSEDSAMPLE | FMOD.MODE.NONBLOCKING;
                    var parameter = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure(parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));

                    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);
                        }
                    }
                    break;
                }
            case FMOD.Studio.EVENT_CALLBACK_TYPE.DESTROY_PROGRAMMER_SOUND:
                {
                    var parameter = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure(parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));
                    var sound = new FMOD.Sound(parameter.sound);
                    sound.release();

                    break;
                }
            case FMOD.Studio.EVENT_CALLBACK_TYPE.DESTROYED:
                {
                    // Now the event has been destroyed, unpin the string memory so it can be garbage collected
                    stringHandle.Free();

                    break;
                }
        }
        return FMOD.RESULT.OK;
    }

    void Update()
    {
        //dialogueInstance.getTimelinePosition(out int position);
        //Debug.Log(position);
        if (Input.GetKeyDown(KeyCode.Space))
        {
            PlayDialogue(dialogueKey);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            PlayDialogue("640165main_Lookin At It");
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            PlayDialogue("640169main_Press to ATO");
        }
    }
}

```

I’ll try changing the sound mode and see if that helps. Thanks!

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 5, 2023, 9:27am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/4 "2023-04-05T09:27:34Z")

</div>

**Update** I’ve made the changes the soundMode variable you recommended and I got this warning instead:

> [FMOD] EventInstance::createProgrammerSoundImpl : Programmer sound callback for instrument ‘’ returned no sound.  
> UnityEngine.Debug:LogWarning (object)  
> FMODUnity.RuntimeUtils:DebugLogWarning (string) (at Assets/Plugins/FMOD/src/RuntimeUtils.cs:558)  
> FMODUnity.RuntimeManager:DEBUG\_CALLBACK (FMOD.DEBUG\_FLAGS,intptr,int,intptr,intptr) (at Assets/Plugins/FMOD/src/RuntimeManager.cs:81)

---

<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:** [April 6, 2023, 4:43am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/5 "2023-04-06T04:43:49Z")

</div>

Hi,

Thank you for sharing the code.

> [@samdixonmusic](#):
>
> **Update** I’ve made the changes the soundMode variable you recommended and I got this warning instead:

Apologies, that is for when you are using a file rather than an audio table my mistake.

What is the value you are using for `dialogueKey`? Could I also get a screenshot of your `Audio Table` in your FMOD Studio project?  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/7e851e6c256df1ddcba57f1ec84c6131134b56b4.png)

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 11, 2023, 10:06am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/6 "2023-04-11T10:06:38Z")

</div>

Sure thing. Do these screenshots show what you’re looking for?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/709857b8091b00552db8a4e3324d8978ac687204.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/22fe43b7e22828814e0154819e39a61b59e9e58f.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/0c9ea9e20507975e422c0aa592dddb45c04d61b5.png)

And no worries on the script. Should I go ahead and change it back to how it was by default then?

---

<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:** [April 11, 2023, 11:38pm UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/7 "2023-04-11T23:38:47Z")

</div>

Hi, yes they are perfect!

In your first image, you have the key as `Level1_1.Welcome2Cell` in the audio table the key is listed as `en_US/Level1_1.Welcome2Cell` could you try using this as the key instead and see if it solves the issue?

> [@samdixonmusic](#):
>
> And no worries on the script. Should I go ahead and change it back to how it was by default then?

Yes, that can be changed back to the default.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 14, 2023, 9:58am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/8 "2023-04-14T09:58:49Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/db56d2dc2422a23e78ed724c589fe3f86f8f454a.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f8c30c591aa6de8e17b604bae557f47c85dcd482.png)

Tried changing the dialogueKey to accomodate the localisation key (which I’m sure I must have tried earlier), but sadly didn’t help.

---

<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:** [April 16, 2023, 11:34pm UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/9 "2023-04-16T23:34:57Z")

</div>

Would it be possible to get a packaged project [uploaded](https://fmod.com/profile#uploads) to your profile? You will have to register a [project](https://fmod.com/profile#projects) with us to be able to upload the project. When packaging the project please ensure built banks are included:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/59ed0792ab1d2961a3e06f8a835e092cc0933e62.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/d879986ddf278e3c70fee9bfffc23449a95b44ed.png)

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 18, 2023, 9:26am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/10 "2023-04-18T09:26:54Z")

</div>

Sure thing Connor. Just uploaded it to my profile. The event in question is called ‘DogmaDialogue’. It has a corresponding audio table of the same name and both are the only things built to the ‘Dialogue’ bank. There are some other dialogue events in the ‘Master’ bank, but they’re just placeholders for the moment. Let me know if you have any questions about it.

---

<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:** [April 19, 2023, 2:38am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/11 "2023-04-19T02:38:34Z")

</div>

Hi,

Thank you for sharing the project. I think it might be an issue with the `Programmer Instrument` not being able to find the `Audio Table` files.

Could you try relocating the folder containing the `Audio Table` files and rebuilding the banks and making sure that the key is the same as the one in the `Audio Table` window. Let me know how that goes.

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 19, 2023, 3:01pm UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/12 "2023-04-19T15:01:30Z")

</div>

No worries.

> [@Connor\_FMOD](#):
>
> Could you try relocating the folder containing the `Audio Table` files

By this, do you simply mean make sure that the Programmer Instrument sees and has a reference to the Audio Table? (rather than moving the location of the audio table folder itself?) I’ve attached a video of myself recreating the audio table from scratch and hooking it up to the Programmer Instrument. Can you tell from this whether or not I’ve been missing a step?

At the end of all this, I’m still getting the same “Waveform instance in error state 18” warning message. And of course no sound. When I change the dialogue key to one that’s not listed in the audio table, I get a different warning message:

> [FMOD] EventInstance::createProgrammerSoundImpl : Programmer sound callback for instrument ‘’ returned no sound.

> UnityEngine.Debug:LogWarning (object)  
> FMODUnity.RuntimeUtils:DebugLogWarning (string) (at Assets/Plugins/FMOD/src/RuntimeUtils.cs:558)  
> FMODUnity.RuntimeManager:DEBUG\_CALLBACK (FMOD.DEBUG\_FLAGS,intptr,int,intptr,intptr) (at Assets/Plugins/FMOD/src/RuntimeManager.cs:81)

So I’m fairly sure the dialogue key I’ve been using is the correct one.

---

<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:** [April 20, 2023, 1:35am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/13 "2023-04-20T01:35:31Z")

</div>

Apologies, that wasn’t very clear.

Thank you for the video, it might have included what I was missing. `error 18` is `ERR_FILE_NOTFOUND` which I was making me think that it was an issue with the folder directory. Rather it might be you have to enable the `Include sub directories` option in the `Audio Table` view:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f401533f4d121cef76985ae7293f79cee31d2f10.png)

“FMOD Studio searches recursively through every subfolder from the source directory for all audio files if the “Include sub directories” checkbox is checked. If this checkbox is not checked, FMOD Studio searches the directory itself, but none of its subfolders.” ([FMOD Studio | Dialogue and Localization - Audio Tables](https://fmod.com/docs/2.02/studio/dialogue-and-localization.html#audio-tables:~:text=FMOD%20Studio%20searches%20recursively%20through%20every%20subfolder%20from%20the%20source%20directory%20for%20all%20audio%20files%20if%20the%20%22Include%20sub%20directories%22%20checkbox%20is%20checked.%20If%20this%20checkbox%20is%20not%20checked%2C%20FMOD%20Studio%20searches%20the%20directory%20itself%2C%20but%20none%20of%20its%20subfolders)) this would explain why we are getting the `ERR_FILE_NOTFOUND` error. Enable that option and let me know if that helps!

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 21, 2023, 7:09am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/14 "2023-04-21T07:09:22Z")

</div>

Ah! Think I’ve found it!

On a whim, I tried putting in a bunch of other dialogue keys and one of the shorter ones worked! Then I tried converting one of the longer ones from mp3 (yuck I know) to wav and that one worked too. I don’t know what the common thread is here, but it’s at least enough of a thread to pull on. Could it be that programmer instruments don’t play well with different file types?

---

<div class="post-metadata">

**Author:** ![samdixonmusic](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samdixonmusic](https://qa.fmod.com/u/samdixonmusic)\
**Post date:** [April 21, 2023, 7:36am UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/15 "2023-04-21T07:36:08Z")

</div>

Haha! Nope! The common thread was that the dialogue keys that WEREN’T working all had full stops in the title (ie “L1\_1.FileName”). Removing them from the key name fixes the issue with (presumably) any file format.

---

<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:** [April 23, 2023, 10:24pm UTC](https://qa.fmod.com/t/error-using-localised-audio-tables-for-dialogue/20055/16 "2023-04-23T22:24:46Z")

</div>

Hi,

Thank you for sharing the solution. I will make a note to add this to our documentation so it is clearer for others.
