Control duration of the loop region programatically

We’re trying to implement audio events for weapons in our game. Currently, we want to start an event when player starts shooting (and presses down a mouse button), and stop it once the player releases the mouse button. Audio is looped with a loop region, size of which is configured to match rate of fire of a weapon, and it seems to work fine when rate of fire is static.

However, there are certain mechanics in our game which can influence weapon’s rate of fire, for example, increase it by 5%, or something like that. Our problem is, we cannot control the duration of the loop region within the event instance. Is there any solution in our case? Could weapons with variable rate of fire be implemented any other way? Maybe I have just overlooked some way to attach parameters to loop regions?

We’ve already tried to start each shot sound separetely, via core api, but it doesn’t work that well due to minor but noticable jittering of the rate of sounds (possibly caused by synchronization timings between game thread and fmod thread), we wanted to use fmod event to achieve beat-perfect (or at least close to that) rate of audio playback.

Below I am attaching an example of our current setup of the event for rapid weapon shooting. Single shots are implemented with a separate event.

Have you considered using multiple loop regions, each with a different length, and assigning all but the longest loop region a parameter condition? You can see and change the trigger conditions of a loop region in the deck when the loop region is selected in the editor.

A loop region with trigger conditions only causes the playback position to jump back to the start of the loop region if all the trigger conditions are met when the playback position reaches the end of the loop region. Thus, if you create a parameter called something like “rate of fire” and a set of loop regions of different lengths, and then assign each loop region a parameter condition based on a different range of the “rate of fire” parameter, you should get the behavior that you want.