BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_SetConfig Method (BASSConfig, Int32)BASS.NET API for the Un4seen BASS Audio Library
Sets the value of a config option.

Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.12.0
Syntax

[DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)]
public static bool BASS_SetConfig(
	BASSConfig option,
	int newvalue
)

Parameters

option
Type: Un4seen.BassBASSConfig
The option to set the value of... one of the following (BASSConfig).
newvalue
Type: SystemInt32
The new option value (as an int). See the option's documentation for details on the possible values.

Return Value

Type: Boolean
If successful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

Options:

BASS_CONFIG_3DALGORITHMThe 3D algorithm for software mixed 3D channels.

newvalue (int): Use one of these algorithms BASS3DAlgorithm

These algorithms only affect 3D channels that are being mixed in software. You can check if a channel is being software mixed with BASS_ChannelGetInfo(Int32, BASS_CHANNELINFO).

This config option allows you to use higher quality 3D processing on more powerful CPUs, and more efficient 3D processing on less powerful CPUs. Changing the algorithm only affects subsequently created or loaded samples, musics or streams, it does not affect those that already exist.

BASS_CONFIG_ASYNCFILE_BUFFERThe buffer length for asynchronous file reading.

length (int): The buffer length in bytes. This will be rounded up to the nearest 4096 byte (4KB) boundary.

This determines the amount of file data that can be read ahead of time with asynchronous file reading. The default setting is 65536 bytes (64KB).

Using this config option only affects channels that are created afterwards, not any that have already been created. So it is possible to have channels with differing buffer lengths by using this config option each time before creating them.

BASS_CONFIG_BUFFERPlayback buffer length.

newvalue (int): The 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.

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 it's 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 you create afterwards, not the ones 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.

BASS_CONFIG_DEV_BUFFERThe output device buffer length (Linux and Windows CE).

newvalue (int): The buffer length in milliseconds.

The device buffer is where the final mix of all playing channels is placed, ready for the device to play. Its length affects the latency of things like starting and stopping playback of a channel, so you will probably want to avoid setting it unnecessarily high, but setting it too short could result in breaks in the output.

When using a large device buffer, the BASS_ATTRIB_NOBUFFER attribute could be used to skip the channel buffering stage, to avoid further increasing latency for real-time generated sound and/or DSP/FX changes.

Changes to this config setting only affect subsequently initialized devices, not any that are already initialized.

This config option is only available on Linux and Windows CE. The device's buffer is determined automatically on other platforms. On Linux, the driver may choose to use a different buffer length if it decides that the specified length is too short or long. The buffer length actually being used can be obtained with BASS_INFO, like this: latency + minbuf / 2.

BASS_CONFIG_CURVE_VOLVolume translation curve.

newvalue (bool): Volume curve... = linear, = logarithmic.

DirectSound uses logarithmic volume and panning curves, which can be awkward to work with. For example, with a logarithmic curve, the audible difference between 10000 and 9000, is not the same as between 9000 and 8000. With a linear "curve" the audible difference is spread equally across the whole range of values, so in the previous example the audible difference between 10000 and 9000, and between 9000 and 8000 would be identical.

When using the linear curve, the volume range is from 0% (silent) to 100% (full). When using the logarithmic curve, the volume range is from -100 dB (effectively silent) to 0 dB (full). For example, a volume level of 0.5 is 50% linear or -50 dB logarithmic.

The linear curve is used by default.

BASS_CONFIG_CURVE_PANPanning translation curve.

newvalue (bool): Panning curve... = linear, = logarithmic.

The panning curve affects panning in exactly the same way as the volume curve (BASS_CONFIG_CURVE_VOL) affects the volume.

The linear curve is used by default.

BASS_CONFIG_FLOATDSPPass 32-bit floating-point sample data to all DSP functions?

newvalue (bool): If , 32-bit floating-point sample data is passed to all DSPPROC callback functions.

Normally DSP functions receive sample data in whatever format the channel is using, ie. it can be 8, 16 or 32-bit. But using this config option, BASS will convert 8/16-bit sample data to 32-bit floating-point before passing it to DSP functions, and then convert it back after all the DSP functions are done. As well as simplifying the DSP code (no need for 8/16-bit processing), this also means that there is no degradation of quality as sample data passes through a chain of DSP.

This option also affects DX8 effects when using the "without FX flag" DX8 effect implementation. Note that floating-point FX processing requires DX9 or above.

BASS_CONFIG_GVOL_MUSICGlobal music volume.

newvalue (int): MOD music global volume level... 0 (silent) - 10000 (full).

This config option allows you to have control over the volume levels of all the MOD musics, which is useful for setup options (eg. separate music and fx volume controls).

A channel's final volume = channel volume * global volume / max volume. So, for example, if a stream channel's volume is 0.5 and the global stream volume is 8000, then effectively the stream's volume level is 0.4 (0.5 * 8000 / 10000 = 0.4).

BASS_CONFIG_GVOL_SAMPLEGlobal sample volume.

newvalue (int): Sample global volume level... 0 (silent) - 10000 (full).

This config option allows you to have control over the volume levels of all the samples, which is useful for setup options (eg. separate music and fx volume controls).

A channel's final volume = channel volume * global volume / max volume. So, for example, if a stream channel's volume is 0.5 and the global stream volume is 8000, then effectively the stream's volume level is 0.4 (0.5 * 8000 / 10000 = 0.4).

BASS_CONFIG_GVOL_STREAMGlobal stream volume.

newvalue (int): Stream global volume level... 0 (silent) - 10000 (full).

This config option allows you to have control over the volume levels of all the streams, which is useful for setup options (eg. separate music and fx volume controls).

A channel's final volume = channel volume * global volume / max volume. So, for example, if a stream channel's volume is 0.5 and the global stream volume is 8000, then effectively the stream's volume level is 0.4 (0.5 * 8000 / 10000 = 0.4).

BASS_CONFIG_MP3_CODECThe MP3 decoder to use.

newvalue (int): The MP3 decoder to use... 0 = BASS, 1 = Windows.

Most Windows users will have an MP3 codec installed - it comes preinstalled with modern Windows (ME/2K/XP), and can be installed on older Windows, eg. with Windows Media Player. By default, BASS will use it's own built-in MP3 decoder, as it provides better performance, but the Windows codec can be used instead.

When using the Windows codec, BASS still does the file processing, so all the usual features are still supported, including streaming, tag reading, pre-scanning, gapless playback, etc...

If the Windows codec option is chosen, but an MP3 codec is not installed, then MP3 files/streams will not be playable and the stream/sample creation functions will produce a BASS_ERROR_CODEC error.

BASS_CONFIG_MUSIC_VIRTUALThe maximum number of virtual channels to use in the rendering of IT files.

newvalue (int): The number of virtual channels... 1 (min) - 512 (max). If the value specified is outside this range, it is automatically capped.

This setting only affects IT files, as the other MOD music formats do not have virtual channels. The default setting is 64. Changes only apply to subsequently loaded files, not any that are already loaded.

BASS_CONFIG_NET_PLAYLISTProcess URLs in PLS and M3U playlists?

newvalue (int): When to process URLs in PLS and M3U playlists... 0 = never, 1 = in BASS_StreamCreateURL(String, Int32, BASSFlag, DOWNLOADPROC, IntPtr) only, 2 = in BASS_StreamCreateFile(String, Int64, Int64, BASSFlag) and BASS_StreamCreateFileUser(BASSStreamSystem, BASSFlag, BASS_FILEPROCS, IntPtr) too.

BASS_CONFIG_NET_BUFFERInternet download buffer length.

newvalue (int): The buffer length, in milliseconds.

Increasing the buffer length decreases the chance of the stream stalling, but also increases the time taken by BASS_StreamCreateURL(String, Int32, BASSFlag, DOWNLOADPROC, IntPtr) to create the stream, as it has to pre-buffer more data (adjustable via the BASS_CONFIG_NET_PREBUF config option). Aside from the pre-buffering, this setting has no effect on streams without either the BASS_STREAM_BLOCK or BASS_STREAM_RESTRATE flags.

When streaming in blocks, this option determines the download buffer length. The effective buffer length can actually be a bit more than that specified, including data that's been read from the buffer by the decoder but not been used yet.

This config option also determines the buffering used by "buffered" user file streams created with BASS_StreamCreateFileUser(BASSStreamSystem, BASSFlag, BASS_FILEPROCS, IntPtr).

The default buffer length is 5 seconds (5000 milliseconds). The net buffer length should be larger than the length of the playback buffer (BASS_CONFIG_BUFFER), otherwise the stream is likely to briefly stall soon after starting playback.

Using this config option only affects streams created afterwards, not any that have already been created.

BASS_CONFIG_NET_PASSIVEUse passive mode in FTP connections?

passive (bool): If , passive mode is used, otherwise normal/active mode is used.

Changes take effect from the next internet stream creation call. By default, passive mode is disabled.

BASS_CONFIG_NET_PREBUFAmount to pre-buffer when opening internet streams.

newvalue (int): Amount (percentage) to pre-buffer.

This setting determines what percentage of the buffer length (BASS_CONFIG_NET_BUFFER) should be filled by BASS_StreamCreateURL(String, Int32, BASSFlag, DOWNLOADPROC, IntPtr). The default is 75%. Setting this lower (eg. 0) is useful if you want to display a "buffering progress" (using BASS_StreamGetFilePosition(Int32, BASSStreamFilePosition)) when opening internet streams, but note that this setting is just a minimum - BASS will always pre-download a certain amount to verify the stream

As well as internet streams, this config setting also applies to "buffered" user file streams created with BASS_StreamCreateFileUser(BASSStreamSystem, BASSFlag, BASS_FILEPROCS, IntPtr).

BASS_CONFIG_NET_TIMEOUTTime to wait for a server to respond to a connection request.

newvalue (int): The time to wait, in milliseconds.

The default timeout is 5 seconds (5000 milliseconds).

BASS_CONFIG_NET_READTIMEOUTThe time to wait for a server to deliver more data for an internet stream.

newvalue (int): The time to wait, in milliseconds... 0 = no timeout.

When the timeout is hit, the connection with the server will be closed. The default setting is 0, no timeout.

BASS_CONFIG_PAUSE_NOPLAYPrevent channels being played when the output is paused?

newvalue (bool): If , channels can't be played while the output is paused.

When the output is paused using BASS_Pause, and this config option is enabled, channels can't be played until the output is resumed using BASS_Start. Attempts to play a channel will give a BASS_ERROR_START error.

BASS_CONFIG_REC_BUFFERThe buffer length for recording channels.

newvalue (int): The buffer length in milliseconds... 1000 (min) - 5000 (max). If the length specified is outside this range, it is automatically capped.

Unlike a playback buffer, where the aim is to keep the buffer full, a recording buffer is kept as empty as possible and so this setting has no effect on latency. The default recording buffer length is 2000 milliseconds. Unless processing of the recorded data could cause significant delays, or you want to use a large recording period with BASS_RecordStart(Int32, Int32, BASSFlag, RECORDPROC, IntPtr), there should be no need to increase this.

Using this config option only affects the recording channels that are created afterwards, not any that have already been created. So it is possible to have channels with differing buffer lengths by using this config option each time before creating them.

BASS_CONFIG_SRCThe default sample rate conversion quality.

quality (int): The sample rate conversion quality... 0 = linear interpolation, 1 = 8 point sinc interpolation, 2 = 16 point sinc interpolation, 3 = 32 point sinc interpolation. Other values are also accepted.

This config option determines what sample rate conversion quality new channels will initially have, except for sample channels (HCHANNEL), which use the BASS_CONFIG_SRC_SAMPLE setting. A channel's sample rate conversion quality can subsequently be changed via the BASS_ATTRIB_SRC attribute.

The default setting is 1 (8 point sinc interpolation).

BASS_CONFIG_SRC_SAMPLEThe default sample rate conversion quality for samples.

quality (int): The sample rate conversion quality... 0 = linear interpolation, 1 = 8 point sinc interpolation, 2 = 16 point sinc interpolation, 3 = 32 point sinc interpolation. Other values are also accepted.

This config option determines what sample rate conversion quality a new sample channel will initially have, following a BASS_SampleGetChannel(Int32, Boolean) call. The channel's sample rate conversion quality can subsequently be changed via the BASS_ATTRIB_SRC attribute.

The default setting is 0 (linear interpolation).

BASS_CONFIG_UPDATEPERIODUpdate period of playback buffers.

newvalue (int): The update period in milliseconds... 0 = disable automatic updating. The minimum period is 5ms, the maximum is 100ms. If the period specified is outside this range, it is automatically capped.

The update period is the amount of time between updates of the playback buffers of HSTREAM/HMUSIC channels. Shorter update periods allow smaller buffers to be set with the BASS_CONFIG_BUFFER config option, but as the rate of updates increases, so the overhead of setting up the updates becomes a greater part of the CPU usage. The update period only affects HSTREAM and HMUSIC channels, it does not affect samples. Nor does it have any effect on decoding channels, as they are not played.

BASS creates a thread specifically to perform the updating, except when automatic updating is disabled (period=0) - then you must regularly call BASS_Update(Int32) instead. This allows you to synchronize BASS's CPU usage with your program's. For example, in a game loop you could call BASS_Update(Int32) once per frame, which keeps all the processing in sync so that the frame rate is as smooth as possible. BASS_Update(Int32) should be called at least around 8 times per second, even more often if the BASS_CONFIG_BUFFER config option is used to set smaller buffers.

The update period can be altered at any time, including during playback. The default period is 100ms.

BASS_CONFIG_UPDATETHREADSNumber of update threads.

newvalue (int): The number of threads to use... 0 = disable automatic updating.

The number of update threads determines how many HSTREAM/HMUSIC channel playback buffers can be updated in parallel; each thread can process one channel at a time. The default is to use a single thread, but additional threads can be used to take advantage of multiple CPU cores. There is generally nothing much to be gained by creating more threads than there are CPU cores, but one benefit of using multiple threads even with a single CPU core is that a slow updating channel need not delay the updating of other channels.

When automatic updating is disabled (threads = 0), BASS_Update(Int32) or BASS_ChannelUpdate(Int32, Int32) should be used instead.

The number of update threads can be changed at any time, including during playback.

BASS_CONFIG_VERIFYThe amount of data to check in order to verify/detect the file format.

length (int): The amount of data to check, in bytes... 1000 (min) to 100000 (max). If the value specified is outside this range, it is automatically capped.

Of the file formats supported as standard, this setting only affects the detection of MP3/MP2/MP1 formats, but it may also be used by add-ons (see the documentation). For internet (and "buffered" user file) streams, a quarter of the length is used, up to a minimum of 1000 bytes.

The verification length excludes any tags that may be at the start of the file. The default length is 16000 bytes.

Other config options may be supported by Add-Ons, see the documentation.

ERROR CODEDescription
BASS_ERROR_ILLPARAMoption is invalid.

Examples

Setting the playback buffer to 100ms and the update period to 20ms:
VB
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 100)
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 20)
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 100);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 20);
See Also

Reference