Example, C# Event Player with geometry Occlusion

Version 1.0 - DOWNLOAD THE UNITYPACKAGE at the bottom

Features:

  1. Drag & Drop FMODAsset into Inspector
  2. Automatically creates a List of all parameters & shows their names and min/max values in Inspector
  3. Start On Awake checkbox
  4. [fake] Geometry Occlusion

Setup:

  1. Drag FmodEventPlayer.cs onto GameObject that should emit the sound.
  2. Drag Event from Folder FMODAssets into the Asset field in the Inspector

Events:

Use the following commands to access the event instance:

soundEvent.start()
soundEvent.stop()
soundEvent.release()
etc...

Parameters:

Upon pressing Play in Unity, you’ll find all the event’s parameters within an array in the inspector,
from where they can be accesed using the following syntax:

soundEventParams[0].setValue(newValue);
soundEventParams[1].setValue(newValue);
soundEventParams[3].getValue();
etc...

Note: The Inspector shows the parameters names & even their min/max values.

Occlusion:

!!! For Occlusion to work - your event needs to have a parameter that is called “Occlusion” with min/max values between [0-1].

  1. Tick the Use Occlusion Box
  2. Drag the GameObject that holds your FMOD_Listener Component into the Fmod Listener field in the inspector

TO DO:
-> Add LayerMask Support for Occlusion Linecast

Note: FmodEventPlayer currently uses iTween, which I included in the unitypackage.

The unity package is available here: http://52.88.2.202/forum/download/file.php?id=189

You could make this a tad more user friendly by storing the parameters in a dictionary instead of a standard array. I had a go an this is what I came up with, it works too:

private FMOD.Studio.ParameterInstance p = null;
private FMOD.Studio.PARAMETER_DESCRIPTION description = new PARAMETER_DESCRIPTION();
public Dictionary<string, FMOD.Studio.ParameterInstance> parameters = new Dictionary<string, FMOD.Studio.ParameterInstance>();

void CacheEventParameters()
    {
        int parameterCount;
        ERRCHECK(evt.getParameterCount(out parameterCount));

        for (int i = 0; i < parameterCount; i++)
        {
            ERRCHECK(evt.getParameterByIndex(i, out p));
            ERRCHECK(p.getDescription(out description));
            parameters.Add(description.name, p);
        }
    }

So now you can reference parameters by their actual name instead of remembering their position in an array.

parameters["ParameterName"].SetValue(value);

I personally turned it into a function so all I need to do is call SetParameterValue(string, float).

cool stuff man - that’s really helpful - i never used dictionaries before - so i didn’t know how to do this.

very much appreciated !!! :slight_smile:

Cool stuff, excited to try it out. Would love to see FMOD develop true occlusion and reflections like GSOUND http://gamma.cs.unc.edu/GSOUND/ as well as true HRTF!

Very much appreciated, thank you.