# Directional Audio Emitter

**URL:** <https://qa.fmod.com/t/directional-audio-emitter/11399>\
**Category:** Unity\
**Created:** [April 11, 2014, 5:36pm UTC](https://qa.fmod.com/t/directional-audio-emitter/11399 "2014-04-11T17:36:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradowado](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@bradowado](https://qa.fmod.com/u/bradowado)\
**Post date:** [April 11, 2014, 5:36pm UTC](https://qa.fmod.com/t/directional-audio-emitter/11399/1 "2014-04-11T17:36:39Z")

</div>

Is there a way in fmod to create a directional audio emitter where the sound is projected like a megaphone or a person speaking from their mouth where the emitter sound falls off according to a cone shape instead of the default spherical falloff?

---

<div class="post-metadata">

**Author:** ![bradowado](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@bradowado](https://qa.fmod.com/u/bradowado)\
**Post date:** [April 18, 2014, 4:50am UTC](https://qa.fmod.com/t/directional-audio-emitter/11399/2 "2014-04-18T04:50:56Z")

</div>

OK, figured it out. I’m just calling FMOD\_StudioEventEmitter.StartEvent() and things sound correct now. Seems like a lot of the code snippets that have been posted are outdated now so just calling FMOD\_StudioEventEmitter.StartEvent() seems to work well since I know FMOD has updated that class. I’m using Version 1.03.06 of the Unity integration. Below is my code followed by my settings for the different directional parameters. The last parameter is a custom parameter called “Occlusion” where I intend to eventually fade out the Master volume when the voice emitter is occluded by walls.

It sounds pretty good, although I haven’t tuned it very much. Should work well for a situation where there are lots of characters in a scene (e.g. a cocktail party) where you should be able to focus on different people’s dialogue just by facing them.

I added the FMOD\_StudioEventEmitter.cs script to my emitter object and then the following script to trigger the event:

```auto
using UnityEngine;
using System.Collections;
using FMOD.Studio;

public class SpeechPlayer : MonoBehaviour {

	FMOD_StudioEventEmitter emitter;

	void Start () {
		emitter = transform.GetComponent<FMOD_StudioEventEmitter>();
		emitter.StartEvent();
	}
}
```

Directional Parameter Settings:  
[attachment=0]FMOD\_Directional\_Audio\_Settings.jpg[/attachment]

---

<div class="post-metadata">

**Author:** ![Guest1](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Guest1](https://qa.fmod.com/u/Guest1)\
**Post date:** [April 14, 2014, 12:54am UTC](https://qa.fmod.com/t/directional-audio-emitter/11399/3 "2014-04-14T00:54:02Z")

</div>

Hi bradowado,

The “Built-In” parameters are automatically updated inside FMOD based on the 3D attributes passed in to FMOD. If you’re using the FMODListener and the FMOD\_StudioEventEmitter or FMOD\_StudioSystem.PlayOneShot, this 3D information is already passed through to FMOD. To make a directional sound just create a volume automation controlled by the Cone Angle parameter.

---

<div class="post-metadata">

**Author:** ![bradowado](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@bradowado](https://qa.fmod.com/u/bradowado)\
**Post date:** [April 15, 2014, 7:16am UTC](https://qa.fmod.com/t/directional-audio-emitter/11399/4 "2014-04-15T07:16:43Z")

</div>

I created a volume automation for the Event Cone Angle parameter and set the maximum value = 10, but I don’t hear any effect inside Unity and when I try and get the parameter it returns null. Here is my code which is attached to my Main Camera alongside the FMOD\_Listener script:

```auto
using UnityEngine;
using System.Collections;
using FMOD.Studio;

public class ForumCode : MonoBehaviour {
	FMOD_StudioSystem soundSystem;
	FMOD.Studio.EventInstance speechEvent;
	FMOD.Studio.ParameterInstance coneAngle;
	float pos = 0;
	int parameterCount;

	void Start () {
		//Cache the FMOD_StudioSystem instance for easier access
		soundSystem = FMOD_StudioSystem.instance;
		
		//declare a string variable holding the file name. The Application.dataPath is needed so that
		//the sounds work both in the editor and in standalone builds
		string fileName = Application.dataPath + "/StreamingAssets/Master Bank.bank";
		
		//Load the FMOD bank
		FMOD.Studio.Bank bank;
		FMOD_StudioSystem.ERRCHECK(soundSystem.System.loadBankFile(fileName, LOAD_BANK_FLAGS.NORMAL, out bank));
		//Also load the corresponding strings bank so that we can find the events by their names
		FMOD.Studio.Bank bankStrings;
		FMOD_StudioSystem.ERRCHECK(soundSystem.System.loadBankFile(fileName + ".strings", LOAD_BANK_FLAGS.NORMAL, out bankStrings));
		
		speechEvent = soundSystem.getEvent("event:/Speech");
		var attributes = FMOD.Studio.UnityUtil.to3DAttributes(transform.position);
		FMOD_StudioSystem.ERRCHECK( speechEvent.set3DAttributes(attributes) );

		FMOD_StudioSystem.ERRCHECK(speechEvent.getParameter("AUTOMATIC_EVENT_CONE_ANGLE", out coneAngle));
		FMOD_StudioSystem.ERRCHECK(speechEvent.getParameterCount(out parameterCount));
		
		FMOD_StudioSystem.ERRCHECK(speechEvent.start());
		print ("parameterCount: " + parameterCount + ", coneAngle: " + coneAngle);

	}

	void Update () {

	}

	void OnDisable(){
		FMOD_StudioSystem.ERRCHECK(speechEvent.stop());
		FMOD_StudioSystem.ERRCHECK(speechEvent.release());
	}
}
```

---

<div class="post-metadata">

**Author:** ![bradowado](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@bradowado](https://qa.fmod.com/u/bradowado)\
**Post date:** [April 11, 2014, 5:44pm UTC](https://qa.fmod.com/t/directional-audio-emitter/11399/5 "2014-04-11T17:44:17Z")

</div>

After searching the FMOD Studio Manual I see on pg. 99 that there are the Direction, Elevation and Cone Angle parameters so I’ll look into enabling that in Unity, but if anyone knows some tips for this please let me know!
