Load a sound to an event at runtime in C#

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.

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

1 Like

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.

1 Like

Thanks for the answers.

Indeed! Programmer sounds it was what I was looking for. Thanks to the provided example 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.

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.

1 Like