Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

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

Sumbission failed

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

Close

Cancel

public static function GetDSPBufferSize(bufferLength: int, numBuffers: int): void;
public static void GetDSPBufferSize(int bufferLength, int numBuffers);
public static def GetDSPBufferSize(bufferLength as int, numBuffers as int) as void

Parameters

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

Description

Get or set the mixer's buffer size in samples.

Note that setting a new buffersize will reset the audio system (all audio will stop). For mobiles (iOS devices and Android) the is also settable from the menu 'Audio Settings->Mobile DSP Buffer size'. The software mixer mixes to a ringbuffer. The size of this ringbuffer 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 ringbuffer. Adjusting these values can lead to extremely low latency performance (smaller values), or greater stability in sound output (larger values). Warning! 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 20ms will be noticable and sound parameter changes will be obvious instead of smooth. Unity chooses the most optimal size by default for best stability, depending on the output type, and if the drivers are emulated or not (for example DirectSound is emulated using waveOut on NT). It is not recommended changing this value unless you really need to. You may get worse performance than the default settings chosen by Unity.