Author Topic: BASS_ChannelSetPosition on some MP3 files does not work(MP3-free version issue)  (Read 105 times)

Cristian1980

  • Posts: 60
Hi,

I encountered a issue that is happening on some MP3 files while using MP3-free BASS library.

A short description for what I am doing:
1/ I am setting a specific position in the track using BASS_ChannelSetPosition() and the function return success(that is OK)
2/ I querry the position using BASS_ChannelGetPosition() I get the same position as the one I set.(that is OK)
3/However if I retrieve the data from BASS using BASS_ChannelGetData() the data returned is from another position.(that is NOT OK)

I was lucky enough to find a way to reproduce this and bellow is the test code:

Code: [Select]
BASS_Init(0, 44100, 0, 0, NULL);
HSTREAM _bassFileHandle = BASS_StreamCreateFile(FALSE, "D:\\mp3\\CUE_Issue\\test.mp3", 0, 0, BASS_STREAM_DECODE | BASS_STREAM_PRESCAN | BASS_SAMPLE_FLOAT | BASS_SAMPLE_SOFTWARE );

float *buffer = new float[753664 / 4];
BOOL res = BASS_ChannelSetPosition(_bassFileHandle, 11839928, BASS_POS_BYTE);
printf("set pos returned %d get pos retuned %ld\n", res, BASS_ChannelGetPosition(_bassFileHandle, BASS_POS_BYTE));
DWORD ret = BASS_ChannelGetData(_bassFileHandle, buffer, 753664 | BASS_DATA_FLOAT);

BASS_CHANNELINFO info;
int length = 0;
if (BASS_ChannelGetInfo(_bassFileHandle, &info))
{
length = BASS_ChannelGetLength(_bassFileHandle, BASS_POS_BYTE);
}
float *buffer2 = new float[length / 4];

res = BASS_ChannelSetPosition(_bassFileHandle, 0, BASS_POS_BYTE);
ret = BASS_ChannelGetData(_bassFileHandle, buffer2, length | BASS_DATA_FLOAT);
int idx = 0;
while (true)
{
ret = memcmp(buffer , buffer2+ idx * 2, 753664);
if (!ret)
break;
idx++;
}

printf("data found at position %ld\n", idx * sizeof(float) * 2);

And here is the test track:
https://www.dropbox.com/s/7vug72ifx6mtpx3/test.mp3?dl=0

The code above,  on Windows 7 and Windows 10 using mp3-free bass version, returns:
Quote
set pos returned 1 get pos retuned 11839928
data found at position 80312

If I use the non free MP3 BASS version I am getting expected results:
Quote
set pos returned 1 get pos retuned 11839928
data found at position 11839928

Can you please help?

Best regards,
Cristian

Ian @ un4seen

  • Administrator
  • Posts: 20152
Oops! There is indeed a seeking bug in the current "mp3-free" BASS version when BASS_STREAM_PRESCAN is used on Windows (other platforms are not affected). Here's an update that should fix it:

   www.un4seen.com/stuff/bass-mp3free.zip

Let me know if you still see a problem with that.

Cristian1980

  • Posts: 60
Thank you very much for the quick reply and fix.
I am no longer able to reproduce using this test case, so it seems to be fixed.

I will surely let you know if I find any more issues :)

Best regards,
Cristian