BASS

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 1ms above the update period (BASS_CONFIG_UPDATEPERIOD), 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.

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. Even at this default length, it's still possible that the sound could break up on some systems, it's 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.

Example

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

See also

BASS_GetConfig, BASS_GetInfo, BASS_SetConfig, BASS_ATTRIB_NOBUFFER, BASS_CONFIG_UPDATEPERIOD