BASS_CONFIG_BUFFER config option


The playback buffer length for HSTREAM and HMUSIC channels.

BASS_SetConfig(
    BASS_CONFIG_BUFFER,
    DWORD length
);

Parameters

lengthThe buffer length in milliseconds. The minimum length is 10ms, the maximum is 5000 milliseconds. If the length specified is outside this range, it is automatically capped.

Remarks

The default buffer length is 500 milliseconds. Increasing the length, decreases the chance of the sound possibly breaking-up on slower computers, but also increases the latency for DSP/FX. The buffer length should always be greater than the update period (BASS_CONFIG_UPDATEPERIOD), which determines how often the buffer is refilled.

Small buffer lengths are only required if the sound is going to be changing in real-time, for example, in a soft-synth. If you need to use a small buffer, then the minbuf member of BASS_INFO should be used to get the recommended minimum buffer length supported by the device and its drivers, and add that to the update period plus some margin for the stream's processing. Even then, it is still possible that the sound could break up on some systems, it is also possible that smaller buffers may be fine. So when using small buffers, you should have an option in your software for the user to finetune the length used, for optimal performance.

Using this config option only affects the HMUSIC/HSTREAM channels that are created afterwards, not any that have already been created. So you can have channels with differing buffer lengths by using this config option each time before creating them.

If automatic updating is disabled, make sure you call BASS_Update frequently enough to keep the buffers updated.

Platform-specific

Except on Windows, the BASS_ATTRIB_NOBUFFER option can be used to bypass the playback buffer for low latency output.

Example

Use the recommended minimum buffer length with 1ms margin.
DWORD len=BASS_GetConfig(BASS_CONFIG_UPDATEPERIOD); // get update period
BASS_INFO info;
BASS_GetInfo(&info); // retrieve device info
len+=info.minbuf+1; // add the 'minbuf' plus 1ms margin
BASS_SetConfig(BASS_CONFIG_BUFFER, len); // set the buffer length

See also

BASS_GetConfig, BASS_GetInfo, BASS_SetConfig, BASS_ATTRIB_NOBUFFER, BASS_CONFIG_UPDATEPERIOD