Hello! Have some problems with Command Instrument

Hello!

We faced with one problem in command instrument.
In instance we have multiinstrument with 3 sounds.
And loop, end-loop event which trigger when “var” equals zero.
Also we have command instrument, which increment “var” on -1, until zero.

Logic is simple, “var” define through the code, for example 5. Instance play 5 times and loop is finished.

But some strange behaviour happens when our timeline is short, for example loop near 0.2 sec or 0.4 sec.
“Var” = 1, But it could loop twice.
It seems like command instrument isn’t enough fast to increment “var”.

Because, when loop big enough, more than 2 seconds, it works correctly.

In general how we should know when command instrument will be triggered and value will be incremented (Doest it depends on length of command instrument?)

We’ll be very pleasant to you, if you give advice how to resolve that or any workarounds.

Fmod version: FMOD Studio 2.01.11

With regards from our team!

Maybe could you work around this problem by setting a max count per instrument?

It doesn’t depend on the length of the command instrument, but it does depend on the distance between the start of the command instrument and the end of the loop region.

Because audio processing is never truly instantaneous, any change to how the playback position is going to move needs to be scheduled a short while in advance. This means that if the parameter value changes a very short time before the end of the loop region, the loop region does not have time to react to the change in parameter value by switching itself off.

In addition, commands issues by command instruments are also not processed instantly, but must wait for the next time update() is called.

These two facts combined mean that if the start of a set parameter command instrument is only a short distance before the end of a loop region whose triggering depends on the value of the parameter set by that command instrument, the loop region may not react to the change in the parameter value in the same loop in which the command instrument is triggered and causes the parameter value to change.

Move the command instrument from the end of the loop region to the start. This will increase the amount of time between the command being triggered and the end of the loop region being reached.