Playing Unity AudioClip in FMOD as Programmer Sound


I am a bit lost on how exactly FMOD can receive information taken from an AudioClip in Unity, and how this can be used to eventually create a Programmer Sound.

I’ve followed the general advice here: How to create programmer sound from AUDIOCLIP

But I’m still not sure what to put as the SoundRequirements parameters in the attached image.

Also attached is the full script I’m attempting to use based off the above post.

Thank you!

AudioClipTest.txt (7.9 KB)


Thank you for adding the full script.

I have updated your code with some more comments explaining what is going on in a bit more detail.

public void PlayClipInFmod(AudioClip audioclip)
	UnityEngine.Debug.Log("PlayClipinFmod " +;
	// Get the sample data from the clip and assign in to an array 
	float[] audioclip_data = new float[audioclip.samples * audioclip.channels];
	audioclip.GetData(audioclip_data, 0);

	// We no longer require the 'key' parameter as it was used to access the FMOD audio table. 
	// string key =; 

	// We are getting the information out of the Unity Audio clip passed into the function 
	SoundRequirements sound_requirements = new SoundRequirements(
		// The name of the clip we are playing, makes it easier to identify when in code,
		// Parameters required to create sound exit info:
		// The sample data that will be copied into the sound when we create it 

	// Renamed this for clarity. 
	var audioClipInstance = FMODUnity.RuntimeManager.CreateInstance(EventName);

	// Instead of passing in the key we will pass in the sound requirements that we have created. 
	GCHandle stringHandle = GCHandle.Alloc(sound_requirements);

	// The callback to make the create the sound and assign it to the instance 
	// Play the sound 

	// Release the memory, however if you would like to access parameters or other functions of the instane, 
	// you don't have to release it now. 

I have also uploaded the edited script.
AudioClipTest.txt (7.4 KB)

Hope this helps!

1 Like

A great help!

Thank you!

1 Like