I'm making an mp3 player app with CircuitPython. I've discovered that some (many) mp3s have pops during playback. I believe these are due to arithmetic overflows in the mp3 decoder.
One such track is Bartlebeats - Frequency - 02 Carpter.mp3. A "pop" can be heard just after the start of the song, at around 0.42 seconds. In this screenshot, I visualize the result of decoding this mp3 with the "standalone" decoder in Adafruit_MP3 (top) and with Audacity's own mp3 decoder (bottom).
The samples were manually trimmed from the start of Audacity's mp3 decode in order to make things "line up"; Audacity shows an extra frame of silence at the start, compared to adafruit_mp3.
The pop exists when playing back on real ARM hardware (adafruit pygamer with circuitpython 5.3.0), or when building the standalone program on 32-bit or 64-bit Linux. (however, the standalone decoder is broken right this second, a pull request will be incoming)
Just the first ~170kB of the track suffices to reproduce: testcase.zip
~/src/Adafruit_MP3/examples/standalone$ make && ./decoder testcase.mp3 testcase.bin
make: 'decoder' is up to date.
probable overflow, left channel, frame 18 sample 57, 58
Consecutive sample values: 32729 -32757
probable overflow, left channel, frame 18 sample 58, 59
Consecutive sample values: -32757 32761
MP3Decode
(the last "MP3Decode" print is a fatal decoding error, because the mp3 file was improperly truncated for the sake of making it easy to create. The full file does not produce such an error)
I'm making an mp3 player app with CircuitPython. I've discovered that some (many) mp3s have pops during playback. I believe these are due to arithmetic overflows in the mp3 decoder.
One such track is Bartlebeats - Frequency - 02 Carpter.mp3. A "pop" can be heard just after the start of the song, at around 0.42 seconds. In this screenshot, I visualize the result of decoding this mp3 with the "standalone" decoder in Adafruit_MP3 (top) and with Audacity's own mp3 decoder (bottom).
The samples were manually trimmed from the start of Audacity's mp3 decode in order to make things "line up"; Audacity shows an extra frame of silence at the start, compared to adafruit_mp3.
The pop exists when playing back on real ARM hardware (adafruit pygamer with circuitpython 5.3.0), or when building the standalone program on 32-bit or 64-bit Linux. (however, the standalone decoder is broken right this second, a pull request will be incoming)
Just the first ~170kB of the track suffices to reproduce: testcase.zip
0002-standalone-Print-info-about-likely-overflows.patch.txt 0001-assembly-Implement-SAR64_clip-for-generic-version.patch.txt
(the last "MP3Decode" print is a fatal decoding error, because the mp3 file was improperly truncated for the sake of making it easy to create. The full file does not produce such an error)