BASS_Mixer_ChannelGetPosition reporting incorrect time at a single moment

Started by Salman Ahmed,

Salman Ahmed

Hello,

I'm a developer in osu!(lazer), and for some time now we've been repeatedly seeing reports of what is essentially BASS reporting incorrect time from the mixer for a single moment/frame.

To be more specific, we have a mixer and we add a stream to it, then we call BASS_Mixer_ChannelGetPosition every frame to know at which point are we in the mixer/stream, then, at a very random occurrence, the mixer reports a time that is roughly 11-12 seconds backwards from the current time for only a single frame.

Here's a snippet from our logs showing this:
2024-08-08 16:34:47 [verbose]: TrackBass.UpdateState(): current time = 99776.35416666666
2024-08-08 16:34:47 [verbose]: TrackBass.UpdateState(): current time = 99777.52083333333
2024-08-08 16:34:47 [verbose]: TrackBass.UpdateState(): current time = 88916.60416666667
2024-08-08 16:34:47 [verbose]: TrackBass.UpdateState(): current time = 99779.85416666667
2024-08-08 16:34:47 [verbose]: TrackBass.UpdateState(): current time = 99781.02083333333

Ian @ un4seen

That's strange. Please confirm what platform that's on, and what BASS and BASSmix versions you're currently using (with BASS_GetVersion and BASS_Mixer_GetVersion). And then also give these latest builds a try (if Windows) and see if you still have the problem with them:

   www.un4seen.com/stuff/bass.zip
   www.un4seen.com/stuff/bassmix.zip

Salman Ahmed


Ian @ un4seen

Yes, you can get the latest macOS builds at those URLs. BASSmix wasn't available but I have added that now too. There's also a BASS_FX update that you can try:

   www.un4seen.com/stuff/bass_fx-osx.zip

Please see if the problem still happens when using them. If it does, to narrow it down, can you try disabling the BASS_FX stuff (ie. skip BASS_FX_TempoCreate and BASS_FX_ReverseCreate) to see if it still happens then?

ppy

Reporting back on Salman's behalf that we are now on the beta version but still seeing this issue occur. We have not yet tried bypassing `BASS_FX` streams yet, so consider this an intermediate update.

Ian @ un4seen

When you tried the beta version(s), did that include the BASS_FX build above, as well as the BASS and BASSmix builds? I ask because the BASS_FX update does include some position reporting/syncing changes.

ppy

Sorry it turns out we didn't properly include the DLLs in the last update >_<.

We'll try again and report back.

ppy

After updating to the beta versions we're seeing unexpected shifts in reported time which result in very weird issues (like time jittering after seeks). I haven't yet had a chance to investigate further, nor check whether – ignoring this – our original issue has improved or not, but due to the new issues we can't easily deploy this to a larger user-base for testing.

Sorry to not provide more specifics, just a heads up to let you know that things are weird.

Ian @ un4seen

That doesn't sound good. To narrow down where the problem is, would it be possible to try disabling the BASS_FX tempo and reverse stuff, and see if it still happens then? Please also confirm whether BASSmix splitters (BASS_Split_StreamCreate) are involved, or only mixers (BASS_Mixer_StreamCreate)?

Wieku

Hi! I think it may be indeed BASS_FX at fault.

Recently I got some reports that seeking is broken with .ogg files (seeking during the silent portion was desyncing playback and getposition, basically get position was counting from requested seek but playback always started after the silence). I decided to check if new BASS version (was using 2.4.16.1, mix 2.4.10 and fx 2.4.12.1) fixes it and it does! But, at the same time, I started getting the same time issue as ppy mentions.

Current versions:
BASS Version:        2.4.17.38
BASS FX Version:     2.4.12.11
BASS Mix Version:    2.4.12.4

I've removed bass_fx from the pipeline and after 10 tests on a 40s ogg I didn't encounter a single backwards time report.

As another step, I decided to downgrade bass_fx to the version I had before (2.4.12.1) and the issue still seems to be fixed.

Given that osu! uses bass_fx 2.4.12.6 it seems that something broke between .1 and .6

Ian @ un4seen

Interesting. Is the reported position (from BASS_Mixer_ChannelGetPosition?) actually going backwards sometimes or is it just not advancing at the expected/consistent rate? And did you have tempo and reverse effects set at the time? If so, could you repeat your tests with only the reverse effect set, and again with only the tempo effect set, to identify which is causing the problem?

The tempo effect processes its source at a slightly variable rate, and the BASS_FX update tries to take consideration of that to give the exact position that's currently being heard, while I believe the previous versions gave a more consistent but possible inaccurate position. So this may explain the position not advancing at the expected rate, if that is the issue you're having. It's also possible there's a bug in it if the position is actually going backwards without the reverse effect enabled.

Wieku

In my case I'm not using the reverse stream. Tempo and pitch were set to default values so it was a base stream being played with BASSFX:
Quotechannel := C.BASS_StreamCreateFile(0, unsafe.Pointer(&wFile[0]), 0, 0, C.DWORD(C.BASS_STREAM_DECODE|C.BASS_STREAM_PRESCAN|C.BASS_UNICODE))
channel = C.BASS_FX_TempoCreate(channel, C.BASS_FX_FREESOURCE|C.BASS_STREAM_DECODE)

C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, 1)
C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS, C.float(4.0))
C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS, C.float(30.0))

C.BASS_Mixer_StreamAddChannel(masterMixer, channel, C.BASS_MIXER_CHAN_NORAMPIN|C.BASS_MIXER_CHAN_BUFFER)

C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_TEMPO, C.float(0))
C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_TEMPO_PITCH, C.float(0))

var freq C.float
C.BASS_ChannelGetAttribute(player.channel, C.BASS_ATTRIB_FREQ, &freq)

//In update loop:

pos := float64(C.BASS_ChannelBytes2Seconds(channel, C.BASS_Mixer_ChannelGetPosition(channel, C.BASS_POS_BYTE)))

C.BASS_Mixer_ChannelGetData(channel, unsafe.Pointer(&fft[0]), C.BASS_DATA_FFT1024)
C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_TEMPO, C.float(0)) // dynamic value, 0 during the test
C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_TEMPO_PITCH, C.float(0)) // dynamic value, 0 during the test
C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_FREQ, C.float(1 * freq)) // dynamic value, freq during the test

Yes, it is actually going backwards:
QuoteBACKWARDS! Old pos: 20015.729166666668 new pos: 9200
JUMP! Old pos: 9200 new pos: 20016.145833333332
2 readings were made ~300us from each other.

Ian @ un4seen

Ah! I think see what's causing the problem now. Here's a BASS_FX update for you to try:

   www.un4seen.com/stuff/bass_fx.zip

Let me know if you still see the problem happening with that, or if you need it for a different platform.

ppy

Sorry for the very late reply.

Quote from: Ian @ un4seenAh! I think see what's causing the problem now. Here's a BASS_FX update for you to try:

   www.un4seen.com/stuff/bass_fx.zip

Let me know if you still see the problem happening with that, or if you need it for a different platform.

Unfortunately this still has the "new" issue that I reported earlier, where seek operations jump around 100% of the time.

Quote from: Ian @ un4seenThat doesn't sound good. To narrow down where the problem is, would it be possible to try disabling the BASS_FX tempo and reverse stuff, and see if it still happens then? Please also confirm whether BASSmix splitters (BASS_Split_StreamCreate) are involved, or only mixers (BASS_Mixer_StreamCreate)?

`Split` is not involved.

I've made a recording to give you an overview of what we're seeing with the new DLL:

https://github.com/ppy/osu/issues/26879#issuecomment-2647178953

In the video, after each seek, the reported time from bass looks to jump backwards slightly and then back forward (maybe 30 ms?). It's more visible when slowed to 25% using tempo adjustment.

When I find the time, I will try and make an isolated reproduction and also re-test without tempo / reverse, but just wanted to get this to you for an initial look in case it's obvious what's going on.

Ian @ un4seen

Since that BASS_FX update, there has also been a BASSmix update:

   www.un4seen.com/stuff/bassmix.zip

Please try that in your test and see whether it makes any difference. Please also have your test call BASS_GetVersion/BASS_Mixer_GetVersion/BASS_FX_GetVersion to confirm that the latest builds are being used.

ppy

I've tested quickly with the updated bassmix, and still seeing the same issue.

2025-02-12 05:30:10 [verbose]: 🔈 BASS initialised
2025-02-12 05:30:10 [verbose]: BASS version:           2.4.17.0
2025-02-12 05:30:10 [verbose]: BASS FX version:        2.4.12.13
2025-02-12 05:30:10 [verbose]: BASS MIX version:       2.4.12.8
2025-02-12 05:30:10 [verbose]: Device:                 Default
2025-02-12 05:30:10 [verbose]: Driver:
2025-02-12 05:30:10 [verbose]: Update period:          5 ms
2025-02-12 05:30:10 [verbose]: Device buffer length:   10 ms
2025-02-12 05:30:10 [verbose]: Playback buffer length: 100 ms

As above, will hopefully put together an isolated repro soon.

Ian @ un4seen

Quote from: ppy2025-02-12 05:30:10 [verbose]: Update period:          5 ms
2025-02-12 05:30:10 [verbose]: Device buffer length:   10 ms
2025-02-12 05:30:10 [verbose]: Playback buffer length: 100 ms

To see if the problem may be related to these settings, please also try with them left at the defaults. If that does prevent the problem, next try putting them back one at a time to find which is causing the problem.

Wieku

The "jumping around" issue still persists with the stream created without bass_fx and with default device/playback/update period settings. I've even changed my audio device's (Scarlett Solo 3rd gen) buffer length to 1024 (from 192) with no improvement:
Timestamp: 2521171us Old pos: 629.3877551020ms, new pos: 17234.2630385488ms !JUMP! // BASS_Mixer_ChannelSetPosition
Timestamp: 2533211us Old pos: 17234.2630385488ms, new pos: 17236.0997732426ms
Timestamp: 2533271us Old pos: 17236.0997732426ms, new pos: 17236.1678004535ms
Timestamp: 2534074us Old pos: 17236.1678004535ms, new pos: 17236.9614512472ms
Timestamp: 2534953us Old pos: 17236.9614512472ms, new pos: 17237.8458049887ms
Timestamp: 2535842us Old pos: 17237.8458049887ms, new pos: 17238.7301587302ms
Timestamp: 2536706us Old pos: 17238.7301587302ms, new pos: 17239.5918367347ms
Timestamp: 2537597us Old pos: 17239.5918367347ms, new pos: 17240.4761904762ms
Timestamp: 2538478us Old pos: 17240.4761904762ms, new pos: 17241.3605442177ms
Timestamp: 2539349us Old pos: 17241.3605442177ms, new pos: 17242.2448979592ms
Timestamp: 2540215us Old pos: 17242.2448979592ms, new pos: 17243.1065759637ms
Timestamp: 2541100us Old pos: 17243.1065759637ms, new pos: 17233.9909297052ms !BACKWARDS!
Timestamp: 2541978us Old pos: 17233.9909297052ms, new pos: 17234.8752834467ms
Timestamp: 2542841us Old pos: 17234.8752834467ms, new pos: 17235.7369614512ms
Timestamp: 2543710us Old pos: 17235.7369614512ms, new pos: 17236.5986394558ms
Timestamp: 2544585us Old pos: 17236.5986394558ms, new pos: 17237.4829931973ms
Timestamp: 2545453us Old pos: 17237.4829931973ms, new pos: 17238.3446712018ms
Timestamp: 2546321us Old pos: 17238.3446712018ms, new pos: 17239.2063492063ms
Timestamp: 2547192us Old pos: 17239.2063492063ms, new pos: 17240.0907029478ms
Timestamp: 2548055us Old pos: 17240.0907029478ms, new pos: 17240.9523809524ms
Timestamp: 2548935us Old pos: 17240.9523809524ms, new pos: 17241.8367346939ms
Timestamp: 2549809us Old pos: 17241.8367346939ms, new pos: 17242.6984126984ms
Timestamp: 2550682us Old pos: 17242.6984126984ms, new pos: 17243.5600907030ms
Timestamp: 2551558us Old pos: 17243.5600907030ms, new pos: 17234.4444444444ms !BACKWARDS!
Timestamp: 2552416us Old pos: 17234.4444444444ms, new pos: 17235.3061224490ms
Timestamp: 2553294us Old pos: 17235.3061224490ms, new pos: 17236.1904761905ms
Timestamp: 2554165us Old pos: 17236.1904761905ms, new pos: 17237.0521541950ms
Timestamp: 2555023us Old pos: 17237.0521541950ms, new pos: 17237.9138321995ms
Timestamp: 2555896us Old pos: 17237.9138321995ms, new pos: 17238.7981859410ms
Timestamp: 2556747us Old pos: 17238.7981859410ms, new pos: 17239.6371882086ms
Timestamp: 2557627us Old pos: 17239.6371882086ms, new pos: 17240.5215419501ms
Timestamp: 2558482us Old pos: 17240.5215419501ms, new pos: 17241.3605442177ms
Timestamp: 2559346us Old pos: 17241.3605442177ms, new pos: 17242.2448979592ms
Timestamp: 2560203us Old pos: 17242.2448979592ms, new pos: 17243.0839002268ms
Timestamp: 2561063us Old pos: 17243.0839002268ms, new pos: 17243.9455782313ms
Timestamp: 2561919us Old pos: 17243.9455782313ms, new pos: 17234.8072562358ms !BACKWARDS!
Timestamp: 2562778us Old pos: 17234.8072562358ms, new pos: 17235.6689342404ms
Timestamp: 2563640us Old pos: 17235.6689342404ms, new pos: 17236.5306122449ms
Timestamp: 2564488us Old pos: 17236.5306122449ms, new pos: 17237.3922902494ms
Timestamp: 2565356us Old pos: 17237.3922902494ms, new pos: 17238.2539682540ms
Timestamp: 2566208us Old pos: 17238.2539682540ms, new pos: 17239.0929705215ms
Timestamp: 2567051us Old pos: 17239.0929705215ms, new pos: 17239.9546485261ms
Timestamp: 2567902us Old pos: 17239.9546485261ms, new pos: 17240.7936507937ms
Timestamp: 2568767us Old pos: 17240.7936507937ms, new pos: 17241.6553287982ms
Timestamp: 2569621us Old pos: 17241.6553287982ms, new pos: 17242.5170068027ms
Timestamp: 2570486us Old pos: 17242.5170068027ms, new pos: 17243.3786848073ms
Timestamp: 2571345us Old pos: 17243.3786848073ms, new pos: 17234.2403628118ms !BACKWARDS!
Timestamp: 2572215us Old pos: 17234.2403628118ms, new pos: 17235.1020408163ms
Timestamp: 2573068us Old pos: 17235.1020408163ms, new pos: 17235.9637188209ms
Timestamp: 2573922us Old pos: 17235.9637188209ms, new pos: 17236.8027210884ms
Timestamp: 2574778us Old pos: 17236.8027210884ms, new pos: 17237.6643990930ms
Timestamp: 2575642us Old pos: 17237.6643990930ms, new pos: 17238.5487528345ms
Timestamp: 2576500us Old pos: 17238.5487528345ms, new pos: 17239.3877551020ms
Timestamp: 2577347us Old pos: 17239.3877551020ms, new pos: 17240.2267573696ms
Timestamp: 2578200us Old pos: 17240.2267573696ms, new pos: 17241.0884353741ms
Timestamp: 2579058us Old pos: 17241.0884353741ms, new pos: 17241.9501133787ms
Timestamp: 2579907us Old pos: 17241.9501133787ms, new pos: 17242.7891156463ms
Timestamp: 2580760us Old pos: 17242.7891156463ms, new pos: 17243.6507936508ms
Timestamp: 2581603us Old pos: 17243.6507936508ms, new pos: 17234.4897959184ms !BACKWARDS!
Timestamp: 2582453us Old pos: 17234.4897959184ms, new pos: 17235.3287981859ms
Timestamp: 2583310us Old pos: 17235.3287981859ms, new pos: 17236.2131519274ms
Timestamp: 2584160us Old pos: 17236.2131519274ms, new pos: 17237.0521541950ms
Timestamp: 2585027us Old pos: 17237.0521541950ms, new pos: 17237.9138321995ms
Timestamp: 2585883us Old pos: 17237.9138321995ms, new pos: 17238.7755102041ms
Timestamp: 2586734us Old pos: 17238.7755102041ms, new pos: 17239.6145124717ms
Timestamp: 2587600us Old pos: 17239.6145124717ms, new pos: 17240.4988662132ms
Timestamp: 2588442us Old pos: 17240.4988662132ms, new pos: 17241.3378684807ms
Timestamp: 2589297us Old pos: 17241.3378684807ms, new pos: 17242.1995464853ms
Timestamp: 2590144us Old pos: 17242.1995464853ms, new pos: 17243.0385487528ms
Timestamp: 2591001us Old pos: 17243.0385487528ms, new pos: 17243.9002267574ms
Timestamp: 2591845us Old pos: 17243.9002267574ms, new pos: 17234.7392290249ms !BACKWARDS!
Timestamp: 2592710us Old pos: 17234.7392290249ms, new pos: 17235.6009070295ms
Timestamp: 2593556us Old pos: 17235.6009070295ms, new pos: 17236.4399092971ms // Runs normally after that

After set position it seems to run normally for couple ms and then jumps back to starting point. After a few cycles it starts running normally.

BASS Version:        2.4.17.41
BASS FX Version:     2.4.12.13
BASS Mix Version:    2.4.12.8

Wieku

I've realized that mixer's buffer length was set to 0. Even when leaving it at default + default device/playback/update settings the issue still persists, but in a different way. Now it jumps to desired position, immediately jumps 13ms forward, runs for a while and jumps back to an almost desired position:

Timestamp: 3691342us Old pos: 1399.5464852608ms, new pos: 17234.5351473923ms !JUMP! // BASS_Mixer_ChannelSetPosition
Timestamp: 3704471us Old pos: 17234.5351473923ms, new pos: 17247.6643990930ms !JUMP!
Timestamp: 3704530us Old pos: 17247.6643990930ms, new pos: 17247.7324263039ms
Timestamp: 3705469us Old pos: 17247.7324263039ms, new pos: 17248.6621315193ms
Timestamp: 3706472us Old pos: 17248.6621315193ms, new pos: 17249.6598639456ms
Timestamp: 3707470us Old pos: 17249.6598639456ms, new pos: 17250.6575963719ms
Timestamp: 3708476us Old pos: 17250.6575963719ms, new pos: 17251.6780045351ms
Timestamp: 3709473us Old pos: 17251.6780045351ms, new pos: 17252.6757369614ms
Timestamp: 3710466us Old pos: 17252.6757369614ms, new pos: 17253.6734693878ms
Timestamp: 3711474us Old pos: 17253.6734693878ms, new pos: 17254.6712018141ms
Timestamp: 3712466us Old pos: 17254.6712018141ms, new pos: 17255.6689342404ms
Timestamp: 3713468us Old pos: 17255.6689342404ms, new pos: 17256.6666666667ms
Timestamp: 3714460us Old pos: 17256.6666666667ms, new pos: 17257.6643990930ms
Timestamp: 3715468us Old pos: 17257.6643990930ms, new pos: 17258.6621315193ms
Timestamp: 3716474us Old pos: 17258.6621315193ms, new pos: 17259.6598639456ms
Timestamp: 3717458us Old pos: 17259.6598639456ms, new pos: 17260.6575963719ms
Timestamp: 3718466us Old pos: 17260.6575963719ms, new pos: 17261.6780045351ms
Timestamp: 3719465us Old pos: 17261.6780045351ms, new pos: 17262.6530612245ms
Timestamp: 3720469us Old pos: 17262.6530612245ms, new pos: 17263.6734693878ms
Timestamp: 3721468us Old pos: 17263.6734693878ms, new pos: 17264.6712018141ms
Timestamp: 3722464us Old pos: 17264.6712018141ms, new pos: 17265.6689342404ms
Timestamp: 3723472us Old pos: 17265.6689342404ms, new pos: 17266.6666666667ms
Timestamp: 3724468us Old pos: 17266.6666666667ms, new pos: 17267.6643990930ms
Timestamp: 3725463us Old pos: 17267.6643990930ms, new pos: 17268.6621315193ms
Timestamp: 3726474us Old pos: 17268.6621315193ms, new pos: 17269.6598639456ms
Timestamp: 3727477us Old pos: 17269.6598639456ms, new pos: 17270.6802721088ms
Timestamp: 3728466us Old pos: 17270.6802721088ms, new pos: 17271.6780045351ms
Timestamp: 3729469us Old pos: 17271.6780045351ms, new pos: 17272.6757369614ms
Timestamp: 3730466us Old pos: 17272.6757369614ms, new pos: 17273.6734693878ms
Timestamp: 3731473us Old pos: 17273.6734693878ms, new pos: 17274.6712018141ms
Timestamp: 3732463us Old pos: 17274.6712018141ms, new pos: 17275.6689342404ms
Timestamp: 3733467us Old pos: 17275.6689342404ms, new pos: 17276.6666666667ms
Timestamp: 3734469us Old pos: 17276.6666666667ms, new pos: 17277.7097505669ms
Timestamp: 3735459us Old pos: 17277.7097505669ms, new pos: 17278.7074829932ms
Timestamp: 3736457us Old pos: 17278.7074829932ms, new pos: 17279.7052154195ms
Timestamp: 3737444us Old pos: 17279.7052154195ms, new pos: 17280.6802721088ms
Timestamp: 3738439us Old pos: 17280.6802721088ms, new pos: 17281.6780045351ms
Timestamp: 3739422us Old pos: 17281.6780045351ms, new pos: 17282.6530612245ms
Timestamp: 3740418us Old pos: 17282.6530612245ms, new pos: 17283.6507936508ms
Timestamp: 3741403us Old pos: 17283.6507936508ms, new pos: 17284.6485260771ms
Timestamp: 3742389us Old pos: 17284.6485260771ms, new pos: 17285.6235827664ms
Timestamp: 3743369us Old pos: 17285.6235827664ms, new pos: 17286.5986394558ms
Timestamp: 3744352us Old pos: 17286.5986394558ms, new pos: 17287.5963718821ms
Timestamp: 3745339us Old pos: 17287.5963718821ms, new pos: 17288.5714285714ms
Timestamp: 3746319us Old pos: 17288.5714285714ms, new pos: 17289.5464852608ms
Timestamp: 3747300us Old pos: 17289.5464852608ms, new pos: 17290.5442176871ms
Timestamp: 3748280us Old pos: 17290.5442176871ms, new pos: 17291.5192743764ms
Timestamp: 3749253us Old pos: 17291.5192743764ms, new pos: 17292.4943310658ms
Timestamp: 3750230us Old pos: 17292.4943310658ms, new pos: 17293.4693877551ms
Timestamp: 3751203us Old pos: 17293.4693877551ms, new pos: 17294.4444444444ms
Timestamp: 3752179us Old pos: 17294.4444444444ms, new pos: 17295.4195011338ms
Timestamp: 3753147us Old pos: 17295.4195011338ms, new pos: 17296.3945578231ms
Timestamp: 3754148us Old pos: 17296.3945578231ms, new pos: 17297.3922902494ms
Timestamp: 3755138us Old pos: 17297.3922902494ms, new pos: 17298.3673469388ms
Timestamp: 3756127us Old pos: 17298.3673469388ms, new pos: 17299.3650793651ms
Timestamp: 3757110us Old pos: 17299.3650793651ms, new pos: 17300.3628117914ms
Timestamp: 3758093us Old pos: 17300.3628117914ms, new pos: 17301.3378684807ms
Timestamp: 3759078us Old pos: 17301.3378684807ms, new pos: 17302.3129251701ms
Timestamp: 3760086us Old pos: 17302.3129251701ms, new pos: 17303.3333333333ms
Timestamp: 3761065us Old pos: 17303.3333333333ms, new pos: 17304.3083900227ms
Timestamp: 3762070us Old pos: 17304.3083900227ms, new pos: 17305.3061224490ms
Timestamp: 3763074us Old pos: 17305.3061224490ms, new pos: 17306.3038548753ms
Timestamp: 3764068us Old pos: 17306.3038548753ms, new pos: 17307.3015873016ms
Timestamp: 3765046us Old pos: 17307.3015873016ms, new pos: 17308.2766439909ms
Timestamp: 3766050us Old pos: 17308.2766439909ms, new pos: 17309.2970521542ms
Timestamp: 3767047us Old pos: 17309.2970521542ms, new pos: 17310.2947845805ms
Timestamp: 3768038us Old pos: 17310.2947845805ms, new pos: 17311.2925170068ms
Timestamp: 3769038us Old pos: 17311.2925170068ms, new pos: 17312.2902494331ms
Timestamp: 3770019us Old pos: 17312.2902494331ms, new pos: 17313.2653061224ms
Timestamp: 3771000us Old pos: 17313.2653061224ms, new pos: 17314.2403628118ms
Timestamp: 3771994us Old pos: 17314.2403628118ms, new pos: 17315.2380952381ms
Timestamp: 3772981us Old pos: 17315.2380952381ms, new pos: 17316.2131519274ms
Timestamp: 3773962us Old pos: 17316.2131519274ms, new pos: 17317.2108843537ms
Timestamp: 3774962us Old pos: 17317.2108843537ms, new pos: 17318.2086167800ms
Timestamp: 3775961us Old pos: 17318.2086167800ms, new pos: 17319.2063492063ms
Timestamp: 3776947us Old pos: 17319.2063492063ms, new pos: 17320.1814058957ms
Timestamp: 3777936us Old pos: 17320.1814058957ms, new pos: 17321.1791383220ms
Timestamp: 3778921us Old pos: 17321.1791383220ms, new pos: 17322.1541950113ms
Timestamp: 3779916us Old pos: 17322.1541950113ms, new pos: 17323.1519274376ms
Timestamp: 3780891us Old pos: 17323.1519274376ms, new pos: 17324.1269841270ms
Timestamp: 3781875us Old pos: 17324.1269841270ms, new pos: 17325.1247165533ms
Timestamp: 3782865us Old pos: 17325.1247165533ms, new pos: 17326.0997732426ms
Timestamp: 3783843us Old pos: 17326.0997732426ms, new pos: 17327.0748299320ms
Timestamp: 3784831us Old pos: 17327.0748299320ms, new pos: 17328.0725623583ms
Timestamp: 3785806us Old pos: 17328.0725623583ms, new pos: 17329.0476190476ms
Timestamp: 3786788us Old pos: 17329.0476190476ms, new pos: 17330.0226757370ms
Timestamp: 3787773us Old pos: 17330.0226757370ms, new pos: 17331.0204081633ms
Timestamp: 3788759us Old pos: 17331.0204081633ms, new pos: 17331.9954648526ms
Timestamp: 3789781us Old pos: 17331.9954648526ms, new pos: 17333.0158730159ms
Timestamp: 3790736us Old pos: 17333.0158730159ms, new pos: 17233.9909297052ms !BACKWARDS!
Timestamp: 3791725us Old pos: 17233.9909297052ms, new pos: 17234.9659863946ms
Timestamp: 3792707us Old pos: 17234.9659863946ms, new pos: 17235.9410430839ms // Runs normally after that

Ian @ un4seen

To help investigate this, can you provide some bare bones code (with nothing that's unnecessary) that produces the problem, eg. something that just creates a mixer and source, plugs the source into the mixer, seeks the source, and detects the problem?

Wieku

I've tested it a bit more, and this was actually a bug in my code... SetPosition is being applied with ~50ms delay, and I was consistently calling SetPosition until GetPosition reported at least the requested time... No issues after making sure SetPosition is only called once.

So I guess it means ppy's issue is different then.

But before that I've tested the bass_fx fix for those 10s jumps and it's working correctly now.


Nevermind, I was testing it with bassfx out of the loop.

I've tested it with bass_fx now and that's the result:

Timestamp: 922992us Old pos: 1091.4512471655ms, new pos: 1093.0839002268ms
Timestamp: 924216us Old pos: 1093.0839002268ms, new pos: 1094.2630385488ms
setting time 17234ms
Timestamp: 925853us Old pos: 1094.2630385488ms, new pos: 1095.9410430839ms
Timestamp: 927160us Old pos: 1095.9410430839ms, new pos: 1097.1428571429ms
Timestamp: 928234us Old pos: 1097.1428571429ms, new pos: 1098.2539682540ms
Timestamp: 929354us Old pos: 1098.2539682540ms, new pos: 1099.4331065760ms
Timestamp: 930523us Old pos: 1099.4331065760ms, new pos: 1100.5215419501ms
Timestamp: 931652us Old pos: 1100.5215419501ms, new pos: 1101.7460317460ms
Timestamp: 932867us Old pos: 1101.7460317460ms, new pos: 1102.9478458050ms
Timestamp: 934080us Old pos: 1102.9478458050ms, new pos: 1104.1723356009ms
Timestamp: 935296us Old pos: 1104.1723356009ms, new pos: 1105.3741496599ms
Timestamp: 936485us Old pos: 1105.3741496599ms, new pos: 1106.5079365079ms
Timestamp: 937992us Old pos: 1106.5079365079ms, new pos: 1108.0952380952ms
Timestamp: 939154us Old pos: 1108.0952380952ms, new pos: 1109.2290249433ms
Timestamp: 940339us Old pos: 1109.2290249433ms, new pos: 1110.3628117914ms
Timestamp: 941466us Old pos: 1110.3628117914ms, new pos: 1111.5419501134ms
Timestamp: 942649us Old pos: 1111.5419501134ms, new pos: 1112.6984126984ms
Timestamp: 943801us Old pos: 1112.6984126984ms, new pos: 1113.8775510204ms
Timestamp: 944983us Old pos: 1113.8775510204ms, new pos: 1115.0566893424ms
Timestamp: 946185us Old pos: 1115.0566893424ms, new pos: 1116.2811791383ms
Timestamp: 947377us Old pos: 1116.2811791383ms, new pos: 1117.4603174603ms
Timestamp: 948579us Old pos: 1117.4603174603ms, new pos: 1118.5941043084ms
Timestamp: 949721us Old pos: 1118.5941043084ms, new pos: 1119.7959183673ms
Timestamp: 950907us Old pos: 1119.7959183673ms, new pos: 1120.9977324263ms
Timestamp: 952107us Old pos: 1120.9977324263ms, new pos: 1122.1315192744ms
Timestamp: 953252us Old pos: 1122.1315192744ms, new pos: 1123.3333333333ms
Timestamp: 954452us Old pos: 1123.3333333333ms, new pos: 1124.4671201814ms
Timestamp: 955575us Old pos: 1124.4671201814ms, new pos: 1125.6462585034ms
Timestamp: 956882us Old pos: 1125.6462585034ms, new pos: 1126.8707482993ms
Timestamp: 957967us Old pos: 1126.8707482993ms, new pos: 1128.0725623583ms
Timestamp: 959173us Old pos: 1128.0725623583ms, new pos: 1129.2517006803ms
Timestamp: 960368us Old pos: 1129.2517006803ms, new pos: 1130.3854875283ms
Timestamp: 961878us Old pos: 1130.3854875283ms, new pos: 1131.9727891156ms
Timestamp: 963092us Old pos: 1131.9727891156ms, new pos: 1133.1746031746ms
Timestamp: 964284us Old pos: 1133.1746031746ms, new pos: 1134.3764172336ms
Timestamp: 965480us Old pos: 1134.3764172336ms, new pos: 1135.5555555556ms
Timestamp: 966689us Old pos: 1135.5555555556ms, new pos: 1136.7800453515ms
Timestamp: 968198us Old pos: 1136.7800453515ms, new pos: 1138.2086167800ms
Timestamp: 969760us Old pos: 1138.2086167800ms, new pos: 1139.7732426304ms
Timestamp: 970929us Old pos: 1139.7732426304ms, new pos: 1140.9070294785ms
Timestamp: 972050us Old pos: 1140.9070294785ms, new pos: 1142.1315192744ms
Timestamp: 973292us Old pos: 1142.1315192744ms, new pos: 1143.4013605442ms
Timestamp: 974545us Old pos: 1143.4013605442ms, new pos: 1144.5578231293ms
Timestamp: 975770us Old pos: 1144.5578231293ms, new pos: 1145.8049886621ms
Timestamp: 976960us Old pos: 1145.8049886621ms, new pos: 1146.9841269841ms
Timestamp: 978139us Old pos: 1146.9841269841ms, new pos: 1148.1632653061ms
Timestamp: 979344us Old pos: 1148.1632653061ms, new pos: 1149.3650793651ms
Timestamp: 980509us Old pos: 1149.3650793651ms, new pos: 1150.5215419501ms
Timestamp: 981636us Old pos: 1150.5215419501ms, new pos: 1151.7913832200ms
Timestamp: 983119us Old pos: 1151.7913832200ms, new pos: 1153.1746031746ms
Timestamp: 984335us Old pos: 1153.1746031746ms, new pos: 1154.3764172336ms
Timestamp: 985565us Old pos: 1154.3764172336ms, new pos: 1155.6235827664ms
Timestamp: 986795us Old pos: 1155.6235827664ms, new pos: 1156.8707482993ms
Timestamp: 988059us Old pos: 1156.8707482993ms, new pos: 1158.1179138322ms
Timestamp: 989319us Old pos: 1158.1179138322ms, new pos: 1159.3650793651ms
Timestamp: 990525us Old pos: 1159.3650793651ms, new pos: 17419.7505668934ms !JUMP!
Timestamp: 991915us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 993067us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 994198us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 995481us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 996594us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 997772us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 998872us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 999972us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 1042us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 2215us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 3845us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 5036us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 6198us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 7714us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 8921us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 10040us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 11230us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 12427us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 13558us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 14734us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 15881us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 17177us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 18280us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 19470us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 20668us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 21848us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 23015us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 24155us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 25359us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 26556us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 28062us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 29319us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 30508us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 31638us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 32847us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 34023us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 35235us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 36428us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 37939us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 39149us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 40283us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 41511us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 42724us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 43875us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 45003us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 46158us Old pos: 17419.7505668934ms, new pos: 17419.7505668934ms
Timestamp: 47351us Old pos: 17419.7505668934ms, new pos: 17291.4285714286ms !BACKWARDS!
Timestamp: 48528us Old pos: 17291.4285714286ms, new pos: 17292.5170068027ms
Timestamp: 49666us Old pos: 17292.5170068027ms, new pos: 17293.7414965986ms
Timestamp: 50877us Old pos: 17293.7414965986ms, new pos: 17294.9433106576ms
Timestamp: 52070us Old pos: 17294.9433106576ms, new pos: 17296.1451247166ms
Timestamp: 53277us Old pos: 17296.1451247166ms, new pos: 17297.3469387755ms
Timestamp: 54462us Old pos: 17297.3469387755ms, new pos: 17298.4580498866ms

Source code (in go, for some reason I couldn't get Windows to run a c++ program with 1ms period):
package main

/*
#cgo CFLAGS: -I.
#cgo LDFLAGS: -Wl,-rpath,$ORIGIN -L${SRCDIR} -lbass -lbass_fx -lbassmix
#include "bass.h"
#include "bass_fx.h"
#include "bassmix.h"
*/
import "C"

import (
"fmt"
"time"
"unsafe"
)

func main() {
C.BASS_SetConfig(C.BASS_CONFIG_DEV_NONSTOP, 1)

C.BASS_SetConfig(C.BASS_CONFIG_VISTA_TRUEPOS, 0)

C.BASS_SetConfig(68, 1) //OLDGAPS

C.BASS_Init(-1, 44100, 0, nil, nil)

masterMixer := C.BASS_Mixer_StreamCreate(44100, 2, C.BASS_MIXER_NONSTOP)
C.BASS_ChannelSetAttribute(masterMixer, C.BASS_ATTRIB_BUFFER, 0)
C.BASS_ChannelSetDevice(masterMixer, C.BASS_GetDevice())

C.BASS_ChannelPlay(masterMixer, 0)

channel := C.BASS_StreamCreateFile(0, unsafe.Pointer(C.CString("test.mp3")), 0, 0, C.BASS_STREAM_DECODE|C.BASS_STREAM_PRESCAN)

channel = C.BASS_FX_TempoCreate(channel, C.BASS_FX_FREESOURCE|C.BASS_STREAM_DECODE)

C.BASS_ChannelSetAttribute(channel, C.BASS_ATTRIB_VOL, C.float(0.2))

C.BASS_Mixer_StreamAddChannel(masterMixer, channel, C.BASS_MIXER_CHAN_NORAMPIN|C.BASS_MIXER_CHAN_BUFFER)

lastPos := float64(C.BASS_ChannelBytes2Seconds(channel, C.BASS_Mixer_ChannelGetPosition(channel, C.BASS_POS_BYTE))) * 1000

for i := 0; i <= 20000; i++ {
ts := time.Now().Nanosecond() / 1000

musicPos := float64(C.BASS_ChannelBytes2Seconds(channel, C.BASS_Mixer_ChannelGetPosition(channel, C.BASS_POS_BYTE))) * 1000

if i >= 995 && i <= 1150 {
if musicPos < lastPos {
fmt.Println(fmt.Sprintf("Timestamp: %dus Old pos: %.10fms, new pos: %.10fms !BACKWARDS!", ts, lastPos, musicPos))
} else if musicPos-lastPos > 5 {
fmt.Println(fmt.Sprintf("Timestamp: %dus Old pos: %.10fms, new pos: %.10fms !JUMP!", ts, lastPos, musicPos))
} else {
fmt.Println(fmt.Sprintf("Timestamp: %dus Old pos: %.10fms, new pos: %.10fms", ts, lastPos, musicPos))
}
}

if i == 1000 {
C.BASS_Mixer_ChannelSetPosition(channel, C.BASS_ChannelSeconds2Bytes(channel, C.double(17.234)), C.BASS_POS_BYTE)
fmt.Println("setting time 17234ms")
}

lastPos = musicPos

time.Sleep(time.Millisecond)
}
}

Test music: https://incompetech.com/music/royalty-free/mp3-royaltyfree/Le%20Grand%20Chase.mp3

Ian @ un4seen

Thanks for the test code. I'm able to reproduce the problem with that too, and I think I've found the cause of it in the tempo stream position tracking. Here's a BASS_FX update for you to try:

    www.un4seen.com/stuff/bass_fx.zip

Let me know if you still see the problem happening with that.

Wieku

It seems to work correctly now, thanks! I will test more over the weekend and will notify ppy as apparently he can't open BASS forum threads on his browser for some reason.

Oh, also: were the linux/osx builds also updated?

Ian @ un4seen

Strange that ppy is unable to open forum threads - it is only threads or the index too? And do you know what browser he's using, and what error message/code he's getting?

Anyway, good to hear the BASS_FX update is working well so far. As requested, here are Linux and macOS versions of it:

    www.un4seen.com/stuff/bass_fx-linux.zip
    www.un4seen.com/stuff/bass_fx-osx.zip

Wieku

Maybe he will provide more info later but from what I gathered it happens in Safari and disabling JS fixes the issue.