Getting playback position while using BASS_STREAM_DECODE

Started by xfx,

xfx

If I understand correctly, when using the BASS_STREAM_DECODE flag, BASS_ChannelGetPosition will return the decoding position, not the actual playback position.

Is there anyway to get the actual playback position?

Ian @ un4seen

Please confirm how you're playing the stream. If you're playing it through a mixer then you can use BASS_Mixer_ChannelGetPosition to get the position that's currently being heard from the mixer.

xfx

I could have sworn that I tried just that... in any case, just tried it again and it is working perfectly! Thank you!

xfx

One more question: what causes the delay between calling BASS_Mixer_ChannelPlay and the playback to actually start?
Is it the buffering / decoding of the channel?

Is there any way to minimize that delay?

Ian @ un4seen

That delay is most likely from the mixer's playback buffer, as any data already in there needs to be played before getting to data from the new source. You can avoid that by disabling playback buffering on the mixer, like this:

BASS_ChannelSetAttribute(mixer, BASS_ATTRIB_BUFFER, 0);


xfx

Hi Ian, sorry to re-open this topic.

I just noticed that when using my bluetooth headphones I still get the same delay I mentioned earlier.

I don't have a fancy sound card (integrated Realtek) but playback starts immediately with it, however, when starting playback while using the headphones, there's a notable ~0.5 seconds delay. Any idea why this might happen?

(I tried to record a video showing the issue, but as soon as I start recording, the quality of the audio drops significantly and the delay disappears... ??? )

Ian @ un4seen

Were you recording from the same Bluetooth device? It sounds like the device is using the A2DP profile for playback, which has higher quality but also higher latency and doesn't support recording. And it switches to the HSP/HFP profile for playback+recording, which has lower latency but also lower quality. Do you have the same issues when using the device with other (non-BASS) software?

xfx

Yep... just tried it using Audacity and I see the same initial delay.

Do you know of any means I could use to detect when a device is going to introduce such delay?
Even if nothing can be done, it'd be nice to (at least) alert the user that the playback device they are using will introduce some latency and that it is not an inherent problem of the app.

Ian @ un4seen

I'm not sure if there's a better way, but it looks like you can detect a Bluetooth device on Windows by its "device instance path" (shown in the device's properties) beginning with "bthenum" for A2DP profile and "bthhfenum" for HSP/HFP profile. The "device instance path" is available from BASS_GetDeviceInfo, following the driver string:

BASS_DEVICEINFO info;
BASS_GetDeviceInfo(device, &info(;
const char *path = info.driver + strlen(info.driver) + 1;

But if all software is affected by the high latency or low quality, then the user probably won't need to be told about it :)