0
0

Hello fellow FMOD users, I’m wondering How to implement Event.setProperty in the FMOD Event API .. I’ve already successfully managed to set properties using the soundsystem with this function:

[code:2sy39aen]
public void SetMusicEventProperty(MusicParameterList m, float value)
{
ERRCHECK(musicSystem.setParameterValue((uint)m,value));
}[/code:2sy39aen]

where m is an enum containing the Parameter ID:s.

If I am to change a parameter in an event though, the Event.setProperty wants an IntPtr, which i think is why my code isn’t working, as I’m getting an INVALID_PARAM when I try to excecute the function. Well to begin with i don’t understand C# pointers that well yet, but I find it odd that the function wants a pointer, as the musicsystem only wants a float to begin with. Anyway here is the code I’m using to generate this error:
[code:2sy39aen]
public void SetEventProperty(Event target, String propertyName, float value, bool perInstance)
{

        IntPtr ptr;
        unsafe
        {
             ptr = new IntPtr((void*)&value);
        }
        ERRCHECK(target.setProperty(propertyName, ptr, perInstance));
    }[/code:2sy39aen]

Well I ahve a couple of incertaineties, first of all, the IntPtr doesn’t have to contain pointers to a float or Int value ( I think?). What I know as a FACT though is that the sound i want to alter has a parameter called "param01" that contains a value between 0 and 1 which defines the pan of the sound, and I’m trying to do this, where lol is the event:

[code:2sy39aen]fmodEngine.SetEventProperty(lol, "param01",0f, false);[/code:2sy39aen]

I would really like some help to why I’m receiving the INVALID_PARAMETER error. Thank you beforehand
//Tobias

  • You must to post comments
0
0

After much research I found an example in the documentation that alters the parameter of an Event, so my function now looks like this:

[code:1kio7464]public void SetEventProperty(Event target, String propertyName, float value, bool perInstance)
{
EventParameter pm = new EventParameter();
ERRCHECK(target.getParameter(propertyName,ref pm));
pm.setValue(value);
}[/code:1kio7464]

I’m still interested why the previous code i sent didn’t work though 😀

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.