BASS.NET API for the Un4seen BASS Audio LibraryBassAsioBASS_ASIO_GetLatency Method BASS.NET API for the Un4seen BASS Audio Library
Retrieves the latency of input or output channels of the current Asio device

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

[DllImportAttribute("bassasio.dll", CharSet = CharSet.Auto)]
public static int BASS_ASIO_GetLatency(
	bool input
)

Parameters

input
Type: SystemBoolean
Get the input latency? =the output latency.

Return Value

Type: Int32
If successful, the latency in samples is returned, else -1 is returned. Use BASS_ASIO_ErrorGetCode to get the error code.
Remarks

The latency is the delay between the sound being recorded and reaching an ASIOPROC, in the case of input channels. And the delay between the sample data being fed to an ASIOPROC and actually being heard, in the case of output channels. The latency is dependant on the buffer size, as specified in the BASS_ASIO_Start(Int32) call. So the latency should be checked after making that call, not before.

The latency time can by calculated be dividing the sample latency by the device sample rate. When a channel is being resampled, the sample latency will change, but the effective latency time remains constant.

ERROR CODEDescription
BASS_ERROR_INITBASS_ASIO_Init(Int32, BASSASIOInit) has not been successfully called.

Examples

Display the input and output latency, in milliseconds:
VB
Dim rate As Double = BassAsio.BASS_ASIO_GetRate()
Console.WriteLine("Input Latency = {0} ms", BassAsio.BASS_ASIO_GetLatency(True) * 1000.0 / rate)
Console.WriteLine("Output Latency = {0} ms", BassAsio.BASS_ASIO_GetLatency(False) * 1000.0 / rate)
// get the sample rate
double rate = BassAsio.BASS_ASIO_GetRate();
Console.WriteLine("Input Latency = {0} ms", BassAsio.BASS_ASIO_GetLatency(true) * 1000.0 / rate);
Console.WriteLine("Output Latency = {0} ms", BassAsio.BASS_ASIO_GetLatency(false) * 1000.0 / rate);
See Also

Reference