Dynamic firerate for weapon

Hey Guys,
i am trying to make a gunshot loop with a variable as firerate. So i want to jump to the start of the loop sooner, when the firerate ist higher. But i dont see how that would be possible, because as far as i understand transition markers only trigger at a certain condition, for example when my firerate variable would have a certain value. So i would have to create a marker for every firerate possible wich sounds like a nightmare, because that would result in roughly thousand hand placed markers to cover fire intervals up to 1000RPM, where each of them would point at the start of the loop. Is there a better way to do this?

PS: the scenario i want to use this setup would be a gun, that dynamically changes its firerate. So the current firerate would be set in the engine.

An easier way to do this would be to use a scatterer instrument, set its min and max spawn interval to 300 ms, and automate its spawn rate on a parameter that runs from 0-1000, such that spawn rate is 0% at a parameter value of 0 and 500% at a parameter value of 1000. (You might also want to set the instrument’s min and max distance values to 0 to disable the automatic spatialization of spawned sounds, since I imagine you’ll prefer to use a spatializer on the master track for this kind of event.)

That being said, 1000 is a lot of voices for a single object in your game to spawn each minute, and if the audio files you’re using include tails or multiple of these guns are firing at the same time, you’ll likely run out of audible voices in very short order. Does your game actually require that the player be able to set the fire rate of the gun to any value between 0 and 1000 shots per minute? Many games instead use a smaller number of “stepped” fire rates (say, multiples of 100 shots per minute), or have three-part event with one audio file that plays while the gun is spinning up in preparation to fire, a looped audio file that represents the gun firing repeatedly at its maximum firing rate, and another audio file of the gun spinning down again after it finishes firing.

Thank you so much, im still pretty new to fmod, but i will give it a shot and try got get your solution to work.

and yes you may be correct with multiple guns firing at the same time and we will run into that problem, but at the moment all we have are single shot samples. But i think in the long run you are right, we will very likley have to use stitched-together samples or record/buy better ones.

Scatterer instruments can be set with maximum polyphony and Steal Oldest so even at fast firing rates you can keep a low number of polyphony, per gun (but you may still have the problem of a huge number of guns firing - that can be limited via event instances + virtualize for example).

If your weapon fire event has multiple tracks that need to stay in sync (shot + reverb + mechanicals for example), with Scatterers on multiple tracks, there’s a risk they will go out of sync. But you can loop the parts as multi-sounds on separate tracks on the timeline; then you can 1) automate the the Event Master Pitch from the macros by the fire rate parameter and 2) automate the Pitch of each module with an opposite pitch curve. So when the whole event pitches up, the timeline runs faster -> the sounds trigger faster; then the opposite pitch envelope keeps them at the same pitch even if they trigger at a faster rate.

This way you can have a variable rate of fire / triggering for multi-layer events as well. NOTE: Multi-sounds can also have their own retrigger polyphony / stealing settings, so you can set them to 2-3 channels and Steal Oldest to maintain a suitably low polyphony within the event.

that sounds like a clever idea, i will defenitely try that out. But i thought that the sample quality would suffer from pitching down, because you would stretch the same audio material over a larger timespan than normal, isnt that a thing?

The final pitch is resolved at master level, so if one automation pitches up the whole event, then another automation lowers the pitch by the same amount, no resampling (thus no quality degradation) will take place.

This is a very clever approach, but if I have a weapon that shoots very fast, FMOD stops playing every other sound or so. I get stuttering etc. I have a very fast weapon and it has to be able to scale up/down quite a lot. And at the highest frequences, I get audio stutter. No matter what, the voice is set to max 1 it seems. (when using the profiler). Doesnt matter if I set the multi instrument polyphony to infinite.

The scatterer instrument seems to handle this better (Though I need to set the polyphony up if the fire rate is set high in order to not get stuttering). But then I’m missing out on being able to have different layers.

Thanks

Without being able to see your project, it’s difficult for us to determine the cause of this issue. If you’re spawning new sounds so frequently that it’s happening multiple times every update, it’s possible that some are starting and playing at exactly the same time - but again, it’s impossible for us to tell if that’s the case without seeing your project and a recorded profiler session.

I’m not sure why this should be the case. When I test here, it is trivially possible to achieve polyphony by triggering a multi instrument multiple times, provided the instrument is asynchronous. If your instruments are instead synchronous, try setting them to be asynchronous by selecting them and clicking their “Async” buttons in the deck.