# Load a sound to an event at runtime in C#

**URL:** <https://qa.fmod.com/t/load-a-sound-to-an-event-at-runtime-in-c/17301>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [June 7, 2021, 3:30pm UTC](https://qa.fmod.com/t/load-a-sound-to-an-event-at-runtime-in-c/17301 "2021-06-07T15:30:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![densiwol](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@densiwol](https://qa.fmod.com/u/densiwol)\
**Post date:** [June 7, 2021, 3:30pm UTC](https://qa.fmod.com/t/load-a-sound-to-an-event-at-runtime-in-c/17301/1 "2021-06-07T15:30:09Z")

</div>

Hey there!

I’m in a project that generates “.wav” files from TextToSpeech at runtime (Unity). How can I use that sound as an event. (Later I want to use snapshot that are already builded). I have tried with using LowLevelApi but can’t find a function that loads something rather than setUserData(out intPtr).

Thanks a lot, I’m new in posting in forums. Tell me if you need more information or anything you know about fmod/unity.

---

<div class="post-metadata">

**Author:** ![Grhyll](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/grhyll/32/2322_2.png) [@Grhyll](https://qa.fmod.com/u/Grhyll)\
**Post date:** [June 7, 2021, 4:28pm UTC](https://qa.fmod.com/t/load-a-sound-to-an-event-at-runtime-in-c/17301/2 "2021-06-07T16:28:17Z")

</div>

I think you’re looking for programmer instruments! [https://www.fmod.com/resources/documentation-studio?version=2.02&page=glossary.html#programmer-instrument](https://www.fmod.com/resources/documentation-studio?version=2.02&page=glossary.html#programmer-instrument)

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [June 8, 2021, 12:39am UTC](https://qa.fmod.com/t/load-a-sound-to-an-event-at-runtime-in-c/17301/3 "2021-06-08T00:39:37Z")

</div>

As Grhyll says, you’re looking for programmer instruments, which can play loose audio files on a player’s hard drive. The programmer instrument example included in the FMOD API features an example of the relevant syntax.

All the relevant APIs are part of the FMOD Studio API, so you don’t need to use the low level (core) API - unless your game requires it for other reasons, of course.

---

<div class="post-metadata">

**Author:** ![densiwol](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@densiwol](https://qa.fmod.com/u/densiwol)\
**Post date:** [June 8, 2021, 7:31pm UTC](https://qa.fmod.com/t/load-a-sound-to-an-event-at-runtime-in-c/17301/4 "2021-06-08T19:31:07Z")

</div>

Thanks for the answers.

Indeed! Programmer sounds it was what I was looking for. Thanks to the provided [example](https://www.fmod.com/resources/documentation-unity?version=2.01&page=examples-programmer-sounds.html) in Unity Integration. It does not play the sounds in editor but it does in Standalone build (what I wanted).  
Now I have to figure out how to overwrite that file in standalone build hehe.

By the way… How does FMOD Audio Table Source Directory works? In the end those files will be built in other directory (App build).

Thanks again.

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [June 9, 2021, 12:02am UTC](https://qa.fmod.com/t/load-a-sound-to-an-event-at-runtime-in-c/17301/5 "2021-06-09T00:02:36Z")

</div>

> [@densiwol](#):
>
> How does FMOD Audio Table Source Directory works? In the end those files will be built in other directory (App build).

Audio tables are a way of building audio files into a bank when those audio files are not used in any of your FMOD Studio project’s events. You do not need audio tables to play loose audio files on your players’ hard drives.

The audio table source directory is a directory on your (the game developer’s) machine. Any audio files in this directory will be included in the bank associated with the audio table when you build that bank. It is then possible to play these audio files using programmer instruments. This feature is most commonly used for handling in-game dialogue, as the determination of which line of dialogue to play almost always needs to be made by a game’s code rather than set inside FMOD Studio.
