BASS.NET API for the Un4seen BASS Audio LibraryBassAsioBASS_ASIO_ChannelSetVolume Method BASS.NET API for the Un4seen BASS Audio Library
Sets a channel's volume.

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

[DllImportAttribute("bassasio.dll", CharSet = CharSet.Auto)]
public static bool BASS_ASIO_ChannelSetVolume(
	bool input,
	int channel,
	float volume
)

Parameters

input
Type: SystemBoolean
Dealing with an input channel? = an output channel.
channel
Type: SystemInt32
The input/output channel number... 0 = first, -1 = master.
volume
Type: SystemSingle
The volume level... 0 (silent)...1.0 (normal). Above 1.0 amplifies the sound.

Return Value

Type: Boolean
If succesful, then is returned, else is returned. Use BASS_ASIO_ErrorGetCode to get the error code.
Remarks

Apart from the master volume (channel = -1), this function applies a volume level to a single channel, and does not affect any other channels that are joined with it. This allows balance control over joined channels, by setting the individual volume levels accordingly. The final level of a channel is master volume x channel volume.

The volume "curve" is linear, but logarithmic levels can be easily used. See the example below.

ASIO drivers do not provide volume control themselves, so the volume adjustments are applied to the sample data by BASSASIO. This also means that changes do not persist across sessions, and the channel volume levels will always start at 1.0.

When the channel's sample format is DSD, a 0 volume setting will mute the channel and anything else will be treated as 1.0 (normal).

Volume changes take effect from the next ASIO buffer update cycle. That means that if you make multiple volume changes between update cycles, only the final one will have effect. The period of the update cycles is determined by the ASIO buffer length. BASSASIO only ramps volume changes if you specified BASS_ASIO_VOLRAMP with BASS_ASIO_Init(Int32, BASSASIOInit), so there will be a sudden jump/step between the old and new levels if not, which can cause a click if the step is large.

ERROR CODEDescription
BASS_ERROR_INITBASS_ASIO_Init(Int32, BASSASIOInit) has not been successfully called.
BASS_ERROR_ILLPARAMThe input and channel combination is invalid, or volume is below 0.

Examples

Set a logarithmic volume level:
VB
' translate logarithmic dB level to linear
Dim volume As Single = CSng(Math.Pow(10.0, db / 20.0))
' apply it
BassAsio.BASS_ASIO_ChannelSetVolume(False, 0, volume)
// translate logarithmic dB level to linear
float volume = (float)Math.Pow(10d, db / 20d);
// apply it
BassAsio.BASS_ASIO_ChannelSetVolume(false, 0 , volume);
See Also

Reference