Author Topic: Recognizing MP3 length looks wrong in new version of BASS  (Read 172 times)

BajakiGabesz

  • Posts: 11
Hi all,

I faced with a problem while my application trying to recognize the length of the audio. I find that sometimes the lengths are differs from the stored version of the audio length, which checked by old version of BASS.

We have some applications which based on BASS version 2.4.7.1 and newer applications are based on 2.4.12.1

I also checked these files in another applications like Ocenaudio, Audacity, Audition 3. Almost every application gives different length for these files.
The interesting thing there is only some milliseconds differences between old and new BASS recognized length (11-12-13ms). The old BASS values are totally the same as Ocenaudio recognizes that, but as i know it's not based on BASS.

Is it possible that the new version of BASS calculates the lengths on a wrong way? As i saw all of the audio which affected are in MP3 format. It doesn't matter if i use the 64bit or 32bit version of BASS, the result is always the same.

The audio file lengths are looks like these (old version/new version) in milliseconds:
Quote
207000/206973
219533/219521
234814/234803
27115/27103
242703/242692
243000/243435
163082/163044
253048/253036
240169/239870

I tried to get the audio length on the next way:
Code: [Select]
// Tried with this one too: | BASSFlag.BASS_STREAM_PRESCAN
int createdHandle = Bass.BASS_StreamCreateFile(audioFile, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE);

double length = Math.Round(1000 * Bass.BASS_ChannelBytes2Seconds(createdHandle, Bass.BASS_ChannelGetLength(createdHandle, BASSMode.BASS_POS_BYTES)));

If you need it i can send some files which i found problematic.

I hope someone can help me.
Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 20389
To confirm what the file's length actually is, please try converting it to WAV using the pre-compiled WRITEWAV.EXE example included in the BASS package (C\BIN folder) and then compare the length of that with what BASS_ChannelGetLength says. If it doesn't match, please upload an affected file to have a look at here:

   ftp.un4seen.com/incoming/

Note if you need to get the exact length (not just an estimate) of an MP3 file, you should include the BASS_STREAM_PRESCAN flag in the BASS_StreamCreateFile call, which tells it to pre-scan the file for the length (and seek points).