mackron / dr_libs

Audio decoding libraries for C/C++, each in a single source file.
Other
1.24k stars 206 forks source link

LAME tags are not parsed, leading to an incorrect length calculation #263

Open slouken opened 7 months ago

slouken commented 7 months ago

When decoding https://github.com/py-sdl/py-sdl2/blob/master/sdl2/test/resources/soundtest.mp3, the correct length is 0.1502 seconds, but when using dr_mp3, the reported length is 0.209 seconds.

This can cause silence to be played incorrectly, which is especially a problem when looping MP3 files.

This was reported to SDL_mixer in https://github.com/libsdl-org/SDL_mixer/issues/439 and was solved by switching from dr_mp3 to minimp3.

eXpl0it3r commented 3 months ago

Am I understanding this correctly, that this wouldn't just need the parsing of the Xing / Info tag itself, but also subtracting the delay and padding?

In the SFML tests we're getting a relatively large difference in time and sample count. Additionally, the first few samples seem to be zero values instead of the actual sample.

Values on the right is what minimp3 reported:

  CHECK( inputSoundFile.getSampleCount() == 87'798 )
with expansion:
  91008 (0x16380) == 87798 (0x156f6)

  CHECK( inputSoundFile.getDuration() == sf::microseconds(1'990'884) )
with expansion:
  2063673us == 1990884us