BASS_ASIO_GetLatency

Retrieves the latency of input or output channels.

DWORD BASS_ASIO_GetLatency(
    BOOL input
);

Parameters

inputGet the input latency? Else, the output latency.

Return value

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

Error codes

BASS_ERROR_INITBASS_ASIO_Init has not been successfully called.
BASS_ERROR_UNKNOWNSome other mystery problem!

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 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.

Example

Display the input and output latency, in milliseconds.
double rate = BASS_ASIO_GetRate(); // get the sample rate
printf("input latency = %g ms\n", BASS_ASIO_GetLatency(TRUE) * 1000 / rate);
printf("output latency = %g ms\n", BASS_ASIO_GetLatency(FALSE) * 1000 / rate);

See also

BASS_ASIO_GetInfo, BASS_ASIO_GetRate, BASS_ASIO_Start