Author Topic: [Solved] 14 Minute Long Mp3 appears to decode/load incorrectly  (Read 308 times)

Gazoo

  • Posts: 58
Hey BASSers,

I have an mp3 file that's nearly 14 minutes long. I use the latest version BASS to decode the song, but when I call `BASS_ChannelGetData` I get just a little over a minute of the song. Basically missing 90%.

At first I though it was the mp3, so I opened it in Audacity and re-exported it as an mp3 - same outcome.

Then I cut the mp3 down to only 7 minutes and 50 seconds and exported it again. Loads no problem.

Is it possible that BASS has issues loading and decoding this lengthy of an mp3?

Anyone else had similar experiences?

Thanks in advance,

Gazoo
« Last Edit: 6 Aug '22 - 06:03 by Gazoo »

Ian @ un4seen

  • Administrator
  • Posts: 24589
Are you decoding the entire file in a single BASS_ChannelGetData call? If so, that could explain the problem you're having, as BASS_ChannelGetData has a length limit of 268435455 (0xFFFFFFF) bytes per call, ie. it uses 28 bits of the "length" parameter (the high 4 bits are for flags). You can get larger amounts by breaking it down into multiple calls. For example:

Code: [Select]
QWORD done = 0;
while (done < length) {
int got = BASS_ChannelGetData(handle, data + done, min(length - done, 0xfffffff));
if (got <= 0) break;
done += got;
}

Gazoo

  • Posts: 58
This was exactly the issue Ian. Much appreciated. It'd been so long since I implemented this code and I had no idea multiple calls could be needed at times.

Again - thank you so much for the help!