# Most Simple C# Script to play a sound from FMOD

**URL:** <https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791>\
**Category:** Unity\
**Created:** [February 20, 2021, 8:20pm UTC](https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791 "2021-02-20T20:20:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![123qwe](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/123qwe/32/1697_2.png) [@123qwe](https://qa.fmod.com/u/123qwe)\
**Post date:** [February 20, 2021, 8:20pm UTC](https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791/1 "2021-02-20T20:20:29Z")

</div>

Hello, could anyone point me in the direction of the simplest C# code to play a sound in Unity from FMOD, I just can not find this is the FMOD site?  
Thanks

---

<div class="post-metadata">

**Author:** ![Pure](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@Pure](https://qa.fmod.com/u/Pure)\
**Post date:** [February 22, 2021, 12:23am UTC](https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791/2 "2021-02-22T00:23:47Z")

</div>

[FMOD - Scripting Examples | Basic](https://www.fmod.com/resources/documentation-unity?version=2.0&page=examples-basic.html)

Essentially all you need is to refer to the path of the file you wish to play. You can do this by directly entering the string, or by using an FMOD Event path in the inspector. Then you can do things such as start, stop, play, play oneshot, etc.

---

<div class="post-metadata">

**Author:** ![123qwe](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/123qwe/32/1697_2.png) [@123qwe](https://qa.fmod.com/u/123qwe)\
**Post date:** [February 22, 2021, 9:40am UTC](https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791/3 "2021-02-22T09:40:56Z")

</div>

Thanks for the help, this is all I found on the FMOD site, but it doesn’t make any sense to me in terms of putting it into Visual Studio as a script?

//--------------------------------------------------------------------  
// 4: This shows how to create an instance of an Event and manually  
// start it.  
//--------------------------------------------------------------------  
playerState = FMODUnity.RuntimeManager.CreateInstance(PlayerStateEvent);  
playerState.start();

```
    playerIntro = FMODUnity.RuntimeManager.CreateInstance(PlayerIntroEvent);
    playerIntro.start();
```

---

<div class="post-metadata">

**Author:** ![mattiaswargren](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mattiaswargren/32/2922_2.png) [@mattiaswargren](https://qa.fmod.com/u/mattiaswargren)\
**Post date:** [February 24, 2021, 8:52am UTC](https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791/4 "2021-02-24T08:52:20Z")

</div>

Not sure if you are asking for a way to trigger the audio or just play a sound event.

The Unity integration already have a couple of components that lets you select audio events and play based on conditions.

[https://www.fmod.com/resources/documentation-unity?version=2.0&page=game-components.html#studio-event-emitter](https://www.fmod.com/resources/documentation-unity?version=2.0&page=game-components.html#studio-event-emitter)

Otherwise you can just create simple components for your specific needs.

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

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

---

<div class="post-metadata">

**Author:** ![123qwe](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/123qwe/32/1697_2.png) [@123qwe](https://qa.fmod.com/u/123qwe)\
**Post date:** [February 24, 2021, 2:23pm UTC](https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791/5 "2021-02-24T14:23:22Z")

</div>

Many thanks for this, I will research further.

---

<div class="post-metadata">

**Author:** ![NikMikk](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/nikmikk/32/5599_2.png) [@NikMikk](https://qa.fmod.com/u/NikMikk)\
**Post date:** [February 26, 2021, 10:13am UTC](https://qa.fmod.com/t/most-simple-c-script-to-play-a-sound-from-fmod/16791/6 "2021-02-26T10:13:46Z")

</div>

If you’re playing the sounds by yourself you must make sure to call .release after .start() so the audio gets released from memory after it’s done playing.

```auto
[EventRef] public string coolAudioReferenceString;
EventInstance coolAudioEventInstance;

coolAudioEventInstance = FMODUnity.RuntimeManager.CreateInstance(coolAudioReferenceString);
coolAudioEventInstance.start();
coolAudioEventInstance.release(); // <---- This here, mucho importante

```
