Creating a multi-instrument in an action

Hello,

I’m trying to import my game’s previous assets into fmod. I have the following code working to import my sounds into a multi-instrument inside of a timeline. But my audio engineer said they should be in an action sheet.

How might I change this code to create a multi-instrument into an action sheet instead?

for(i = 0; i < data.length; i++){
			console.log("Creating Event: " + data[i].name);
			
			var category = data[i].audioSourceTemplateName.replace("Assets/Audio/SFX/", "").replace(".prefab", "");
			
			folder = studio.project.create("EventFolder");
			folder.name = category;
			
			event = studio.project.create("Event");
			event.name = data[i].name;
			event.folder = folder;
			
			var track = event.masterTrack;
			var multiInstrument = track.addSound(event.timeline, 'MultiSound', 0, 10);
			
			var sounds = data[i].sfxGroupNames;
			for(h = 0; h < sounds.length; h++){	
				var assetNameFixed = sounds[h].substring(7);
				console.log("\t Importing " + assetNameFixed);
				audioFile = studio.project.importAudioFile(assetNameFixed);
				
				var sound = studio.project.create(assetNameFixed);
				sound.audioFile = audioFile;
				sound.owner = multiInstrument;
			}
		}

Extra points if you can tell me why it seem the script created a timeline in a new event by default whereas the GUI doesn’t?

Thanks alot!

Hi,

Unfortunately, adding action sheets to events via the Studio Scripting API is currently bugged. I’ve noted this on our feature/improvement tracker.

My mistake, it’s not bugged - you can create an ActionSheet via the Studio Scripting API and add a MultiSound to it with the following code:

var actionSheet = studio.project.create("ActionSheet");
var sound = studio.project.create('MultiSound');
actionSheet.modules = sound;
event.relationships.parameters.add(actionSheet);
sound.audioTrack = event.masterTrack;

You can also use the following code to add an Multi Instrument to an existing action sheet on an event:

event.parameters.forEach(function (sheet) {
	if (sheet.isOfExactType('ActionSheet')){
		var sound = studio.project.create('MultiSound');
		sound.owner = sheet.modules;
	}
});

As for why your script creates a timeline in a new event, it appears there’s a slight difference between creating an event using the API and using the GUI. If you want to disable the timeline of an event created using the Scripting API, you can set event.timeline.isProxyEnabled to false to disable it, and to true to enable it.