# Help reducing audio latency

**URL:** https://qa.fmod.com/t/help-reducing-audio-latency/16609
**Category:** FMOD Studio
**Created:** [January 3, 2021, 10:37am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609 "2021-01-03T10:37:06Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![KakCAT](https://avatars.discourse-cdn.com/v4/letter/k/a3d4f5/32.png) [@KakCAT](https://qa.fmod.com/u/KakCAT)
#### Post date: [January 3, 2021, 10:37am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/1 "2021-01-03T10:37:07Z")

</div>

Hi, I’m using FMOD and I’m experimenting a big latency when playing sounds. I think the latency is about 140ms.

I’m on Windows 10 64 bits, high end CPU, using FMOD C# bindings supplied by FMOD and mostly using raw C# (not unity)

My init is

```
result=lowLevelSystem.setSoftwareFormat (0,SPEAKERMODE.DEFAULT,0);	// so that can get same frequency as output and avoid some extra latency
result=system.initialize (256,
			FMOD.Studio.INITFLAGS.NORMAL,
			FMOD.INITFLAGS.NORMAL | FMOD.INITFLAGS._3D_RIGHTHANDED,
			IntPtr.Zero);

```

I’m playing the particular sound through FMOD Studio events.

I use system.getEvent at the start of the game, then each time I want to play the sound, I call the event’s createInstance, and finally effectInstance.start to play the sound.

I’ve been searching the forum and used lowLevelSystem.setDSPBufferSize (512,4); to reduce latency a bit (maybe from ~140 to ~100)  
but that is still too big for my project, and I don’t feel like further reducing the DSP buffer size. (256 reduces it to ~80)

All sounds are added into FMOD Studio as wav, although I don’t know is FMS changes the format. The sound is “correctly trimmed” (no extra silence before the sample)

Could you please suggest any more actions to further reduce the latency? It seems like there are 60ms extra latency somewhere not caused by the DSP buffer.

Thanks!

---

<div class="post-metadata">

### Author: ![buffdash](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/buffdash/32/2621_2.png) [@buffdash](https://qa.fmod.com/u/buffdash)
#### Post date: [January 10, 2021, 2:49am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/2 "2021-01-10T02:49:53Z")

</div>

KakCat, this is what I did to get my latency down to about 20ms:

- Firstly, any audio asset that should have low-latency playback must **NOT** be marked as `streaming` in FMOD Studio. Compression doesn’t seem to impact latency, but streaming certainly does.

- Secondly, an FMOD event needs to first be “buffered” by playing it, then immediately pausing it. Then, when it comes time to play the event, just set pause to false (rather than calling the play method).

These two things was all I needed. I reverted my DSP buffer settings back to default after making these changes and that latency was still super low.

---

<div class="post-metadata">

### Author: ![KakCAT](https://avatars.discourse-cdn.com/v4/letter/k/a3d4f5/32.png) [@KakCAT](https://qa.fmod.com/u/KakCAT)
#### Post date: [January 11, 2021, 11:44am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/3 "2021-01-11T11:44:07Z")

</div>

Hi buffdash, thanks for your answer.

I’ve tried the pause method with my version and seemed not to change anything. Then I decided to move to FMOD 2 64bits (long overdue). After changing some code to adhere to the new API your trick seemed to reduce latency a bit, but unfortunately not as much as you could. Increasing the DSP buffer still increases the latency though.

Although the latency now is more bearable than before (50-70 ms) with 512, I’m wonder what I’m doing wrong ☹

I’ll try going with the pause trick for the moment, but I’ll have to really think how to structure the code so that it’s not a mess to just play a sound.

---

<div class="post-metadata">

### Author: ![NickH](https://avatars.discourse-cdn.com/v4/letter/n/7ea924/32.png) [@NickH](https://qa.fmod.com/u/NickH)
#### Post date: [July 21, 2021, 3:55am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/4 "2021-07-21T03:55:57Z")

</div>

I’m also very interested in lowering latency for a rhythm game - any further information would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)
#### Post date: [July 29, 2021, 4:12am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/5 "2021-07-29T04:12:56Z")

</div>

As mentioned previously, the way to reduce latency with FMOD is to use the Core level System::setDSPBufferSize. The documentation contains certain caveats you need to be mindful of.

[https://fmod.com/resources/documentation-api?version=2.00&page=core-api-system.html#system\_setdspbuffersize](https://fmod.com/resources/documentation-api?version=2.00&page=core-api-system.html#system_setdspbuffersize)

---

<div class="post-metadata">

### Author: ![rvangaal](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/rvangaal/32/11_2.png) [@rvangaal](https://qa.fmod.com/u/rvangaal)
#### Post date: [November 15, 2023, 12:56pm UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/6 "2023-11-15T12:56:41Z")

</div>

How do you measure that latency in the first place?  
Is there a way you can determine what is going out the speaker jack, so you don’t need a physical setup (speakers/microphone, input app) to determine latency?

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [November 16, 2023, 1:19am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/7 "2023-11-16T01:19:46Z")

</div>

> [@rvangaal](#):
>
> How do you measure that latency in the first place?

It depends on what exactly you’re trying to measure.

If you want to measure the overall latency between an input and it effect, then recording your own input and the result audio output is usually the best way to do it.

If you want to measure latency that is specifically a result of FMOD, then recording a profiler session via live update, observing when a specific API command is processed in the [API calls view](https://www.fmod.com/docs/2.02/studio/profiling.html#api-calls-view), and comparing it to when the audible effect of that command occurs is a better option.

> [@rvangaal](#):
>
> Is there a way you can determine what is going out the speaker jack, so you don’t need a physical setup (speakers/microphone, input app) to determine latency?

Again, it depends on what exactly you need:

- A recorded profiler session saves the captured output of the FMOD system
- Many audio drivers have a loopback mode or something similar, which will loop back output as an input
- Screen and audio recording programs or functions can record audio output, and can also be helpful in determining how the output syncs with video

---

<div class="post-metadata">

### Author: ![PheonixMetal](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/pheonixmetal/32/7159_2.png) [@PheonixMetal](https://qa.fmod.com/u/PheonixMetal)
#### Post date: [August 31, 2024, 4:38am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/8 "2024-08-31T04:38:08Z")

</div>

Is there an equivalent for this in the FMOD Studio API specifically? I’m making a rhythm game and would love to lower latency but I’m pretty sure setting DSP buffer sizes is exclusive to the FMOD Core API

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [September 3, 2024, 4:50am UTC](https://qa.fmod.com/t/help-reducing-audio-latency/16609/9 "2024-09-03T04:50:48Z")

</div>

The Studio API is built on top of the Core API, so it is entirely possible. To do so, after creating your Studio system, but before initializing it, use [Studio::System::getCoreSystem](https://www.fmod.com/docs/2.02/api/studio-api-system.html#studio_system_getcoresystem) to get the underlying Core system, and then use [System::setDSPBufferSize](https://www.fmod.com/docs/2.02/api/core-api-system.html#system_setdspbuffersize) on the retrieved Core system to set the DSP buffer size.
