Version: 2022.3
LanguageEnglish
  • C#

AudioSettings.GetDSPBufferSize

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Declaration

public static void GetDSPBufferSize(out int bufferLength, out int numBuffers);

Parameters

bufferLength Is the length of each buffer in the ring buffer.
numBuffers Is number of buffers.

Description

Get the mixer's buffer size in samples.

The buffer size can be set from 'Project Settings -> Audio -> DSP Buffer size'.

The software mixer mixes to a ring buffer and the size of this ring buffer is determined here. It mixes a block of sound data every 'bufferLength' number of samples, and there are 'numBuffers' number of these blocks that make up the entire ring buffer. Adjusting these values can lead to extremely low latency performance (smaller values), or greater stability in sound output (larger values). The 'buffersize' is generally best left alone. Making the granularity smaller will just increase CPU usage (cache misses and DSP network overhead). Making it larger affects how often you hear commands update such as volume/pitch/pan changes. Anything above 20 ms will be noticeable and sound parameter changes will be obvious instead of smooth. Unity chooses the most optimal size by default for best stability, considering the output type and the drivers being used. It is not recommended changing this value unless you really need to. You may get worse performance than the default settings chosen by Unity.

Additional resources: Audio Settings.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961