How to set Parameter Velocity from code?


(Ethan Trinh) #1

Hi, I’m trying to implement track fade in, and found out that setting velocity so that the parameter increase gradually works very well inside FMOD Studio editor. Now I would like to do that programmatically from C#, but it seems like there is no API point that allows changing this velocity value. Am I missing anything or is it really not present in the API?


(リチャード清水) #2

Hi Ethan,

Setting the velocity of a parameter is something that can only be done within the FMOD Studio tool. There is no API for setting velocity.

If you’re looking at track fade in, I would recommend putting an AHDSR modulator onto the volume of the track in question. This can also work on the master track’s volume. If you need the fade in specific instruments you can add the AHDSR modulator onto the .

Please take a look at our documentation on AHDSR modulators for more information.

https://www.fmod.com/resources/documentation-studio?page=authoring-events.html#modulation

Thanks,
Richard


(Ethan Trinh) #3

Hey, thanks for replying, but I’m not sure how AHDSR can help me. I have 4 tracks inside an event, and according to gameplay I would like to fade the tracks 2, 3, 4 in and out accordingly, while track 1 always play. The event is for background music, so it would need to loop too. In the doc, AHDSR is described as it only work when an event starts, not in the middle of an event


(リチャード清水) #4

Hi Ethan,

AHDSR modulation can occur whenever the object that’s being modulated is triggered. If you place it onto a track then it will be when that track is triggered (which is when the event starts/stops), but if you place it onto the individual instruments then it will be applied when the instruments are triggered.

From the sounds of it, you wish for tracks 2, 3, and/or 4 to fade in or fade out depending on conditions met in the game world. In these scenarios you can use automation on the volumes of the tracks on the game parameter(s) to ramp in/out based on the parameter value. This in combination with a slower seek speed on the parameter will save you from writing game code to smoothly ramp from one game parameter value to another.

Take a look at the “Music/Basic/Random Layered” event in the Examples project for an example of automating track volumes against a parameter, and have a read of our documentation on seek speed.

https://www.fmod.com/resources/documentation-studio?page=authoring-events.html#parameters

Thanks,
Richard


(Ethan Trinh) #5

Thanks for the pointer to Seek speed, it helps to a certain extent. But if in the future there is a need to vary the fade speed this is still not gonna cut it. I was already using automation, with code to drive the parameter value over a number of frames. It would be nice to have either seek speed or velocity exposed to the API.