Question about BASS_ChannelSetSync and BASS_SYNC_POS

Started by nadia,

nadia

Hello,  ;D
I'm trying to set a position sync, using BASS_ChannelSetSync and BASS_SYNC_POS param, on a stream on which has been applied a different sample rate through the BASS_ChannelSetAttribute function with the BASS_ATTRIB_TEMPO_FREQ attribute.

The stream plays perfectly at the desired sample rate and the sync is triggered on the correct position (respect to what is being heard) when the stream is played at its original sample rate: so far so good.

The timing of the sync seems to loose reliability when the sample rate is higher: it seems to be triggered with a small delay (respect to what is being heard) which appears to be proportional to the applied sample rate; the higher the sample rate, the higher the delay of the trigger.

Is this behavior by design or is this something that could be improved?

Kind regards  ;D

nadia

Ian @ un4seen

Please confirm what BASS_FX version you're using, and how you're detecting the delay.

A tempo stream actually slightly varies the rate it processes the source and averages out to the expected rate, ie. it isn't constant. The updated BASS_FX builds include changes to more accurately track that, whereas the release version just uses the expected rate. I wouldn't expect that to make a massive difference, but if you aren't already using it, please try the latest build:

    www.un4seen.com/stuff/bass_fx.zip

If you are already using that, you can try reverting to the old position tracking with it via the BASS_ATTRIB_TEMPO_OPTION_OLDPOS option (defined as 0x10017 in the updated BASS_FX.H file):

BASS_ChannelSetAttribute(tempostream, BASS_ATTRIB_TEMPO_OPTION_OLDPOS, 1); // use old position calculation

nadia

Hello,  ;D

I'm already using the very latest bass_fx, so I tried your suggestion to use the BASS_ATTRIB_TEMPO_OPTION_OLDPOS attribute but it doesn't change the behaviour I reported; I will try to explain better the issue.

I want to play snippets of the loaded stream at higher speed and each snippet is 500 ms.

Each time a snippet must be played, I calculate the position in bytes where I want to pause playback and set this position into the BASS_ChannelSetSync function, start playback using the BASS_ChannelPlay function and, when the sync invokes the SYNCPROC, I call the BASS_ChannelPause function (from within the SYNCPROC).

In order to check the issue, I've predisposed a sound file which contains silence inside the first 800 ms so, when the first 500 ms snippet is played, I would not expect to hear any sound: this is true when I play the stream at normal speed, but I can hear the first portion of audible audio when the stream is played at 10x, also if the stream is perfectly paused on the requested position.

I hope that this makes more sense.

Kind regards  ;D

nadia

Ian @ un4seen

Non-mixtime sync callbacks aren't guaranteed to be sample-accurate and BASS_ChannelPause doesn't take immediate effect (data already in the device output buffer will still be heard), so you may well hear some sound beyond the sync position, especially when the playback rate is raised. To stop a stream at an exact position, you can instead call BASS_ChannelStop in a mixtime (BASS_SYNC_MIXTIME) sync. If you still hear sound beyond the wanted position, try setting the sync directly on the source instead of the tempo stream. Note that calling BASS_ChannelStop in a mixtime sync ends the stream, so you will need to call BASS_ChannelSetPosition to reset its state before resuming.

Another option is to set the BASS_POS_END position via BASS_ChannelSetPosition, instead of using a sync. You can do that on either the source or the tempo stream (the tempo stream will forward it to the source).

nadia

Hello,

thanks for your suggestions  ;D
It seems that using the BASS_POS_END position via BASS_ChannelSetPosition works quite well in forward direction but it seems to be ignored in reverse direction: is it supposed to work in both directions?

Kind regards

nadia

Ian @ un4seen

The BASS_POS_END option does also apply to reverse streams; it sets the start position for reverse playback. But I don't think it'll work the way you need (stopping at a position) when going in reverse. So you will probably need to use the mixtime BASS_SYNC_POS sync and BASS_ChannelStop method instead.

nadia

Hello,  ;D

indeed I decided to use BASS_SYNC_END when going forward and BASS_SYNC_POS when going reverse: seems to be quite reliable in this way.

Thanks again and kind regards  ;D

nadia