Version
menu
|
Wwise SDK 2025.1.4
|
If you are working on a project that includes a firearm with a rapid rate of fire, such as a machine gun, it can be difficult to accurately synchronize the bullet sounds with the firing action. Because Wwise events are processed asynchronously on the audio thread, there might be a slight delay between the break action and the termination of a gunshot sound if you implement the sound through a Sample Accurate transition on a looping container.
To achieve a sample-accurate trigger rate with rapid gunshots, we recommend that you use MIDI to trigger each bullet sound. PostMIDIOnEvent makes it possible to respect the exact offset (in samples) within a given audio frame, which allows for high accuracy.
A MIDI-based solution requires the following:
AK::SoundEngine::RenderAudio() yourself to place Play and Stop actions on the desired frame. Refer to the Audio Rendering Thread section in Optimizing CPU usage for details. \SDK\samples\IntegrationDemo\DemoPages\DemoMIDIMetronome.cpp and the corresponding documentation is available at Integration Demo Sample (see the MIDI API section).There is a limitation when using MIDI-triggered events in conjunction with Wwise Spatial Audio. MIDI events are triggered internally by the sound engine and might occur between frame boundaries. However, the acoustics simulation is updated before the audio frame begins. If such an event occurs, it might not be possible for the acoustics engine to perform an update in time, which can cause the first frame of audio to be rendered without acoustic path information, resulting in audible glitches. This behavior happens when the first sound played on a Game Object is a sound triggered by MIDI, and the acoustics engine has not yet calculated the sound propagation paths for that Game Object.
As a workaround, play a separate sound on the same Game Object to force the acoustics engine to calculate the sound propagation paths. The Enable Diffraction and Transmission option must be selected for the separate sound. For a sustained event like rapid gunfire, the separate sound (for example, a loop of silence) must be played for the duration of the rapid gunfire event to ensure the paths are calculated when a MIDI event occurs.
Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageRegister your project and we'll help you get started with no strings attached!
Get started with Wwise