# Detect if event has no instruments

**URL:** https://qa.fmod.com/t/detect-if-event-has-no-instruments/16766
**Category:** Unity
**Created:** [February 16, 2021, 3:12pm UTC](https://qa.fmod.com/t/detect-if-event-has-no-instruments/16766 "2021-02-16T15:12:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![PoleaxeGames](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/poleaxegames/32/1933_2.png) [@PoleaxeGames](https://qa.fmod.com/u/PoleaxeGames)
#### Post date: [February 16, 2021, 3:12pm UTC](https://qa.fmod.com/t/detect-if-event-has-no-instruments/16766/1 "2021-02-16T15:12:15Z")

</div>

I am porting Empire of Ember to use FMOD. Empire of Ember already has all sounds assigned using Unity’s AudioSource, however I want to be able to port certain audio situations to use FMOD instead. If for an event there is no assigned instrument, I need to be able to tell that in code to continue to use Unity’s AudioSource.

How do I tell if an event has no assigned instruments?

---

<div class="post-metadata">

### Author: ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)
#### Post date: [February 22, 2021, 4:48am UTC](https://qa.fmod.com/t/detect-if-event-has-no-instruments/16766/2 "2021-02-22T04:48:21Z")

</div>

You are only able to detect this within the FMOD Studio application. You can have something like the following code in the Window \> Console dialog to search each event’s timeline & parameter sheet for instruments.

```auto
var allEvents = studio.project.model.Event.findInstances();
allEvents.forEach(function(event) {
  var allSheets = event.parameters;
  allSheets.push(event.timeline);
  var allModules = [];

  allSheets.forEach(function(sheet) {
  	allModules.push(sheet.modules);
	});
	var merged = [].concat.apply([], allModules); // The Javascript version provided in FMOD Studio does not allow for array.flat()
	if(merged.length <= 0) {
		console.log("Event '" + event.name + "' does not contain any instruments");
	}
})

```

You can then use this information to tell Unity which events to use the original AudioSource.
