I noticed a few people (myself included) were running into issues trying to create seamless audio loops when exporting to the recommended IMA ADPCM (WAV) format.
"Because ADPCM uses sample blocks that are aligned one after the other, a wave compressed with ADPCM may have an unfinished, partial block at its end. The ADPCM decoder generates silence for the remainder of this partial block, which keeps the wave from looping seamlessly.”
I was noticing an unexpected pop when my audio track looped and had mistakenly assumed it was a hardware limitation of the Playdate, but it turns out it's part of the ADPCM spec.
I noticed this with both Audacity (3.1.3) and ffmpeg exports on Windows. Apparently this doesn't happen using WavePad to export but I didn't confirm.
An ugly workaround is something like this:
local music = playdate.sound.fileplayer.new("some_music_track")
music:setLoopRange(0, music:getLength() - 0.05) -- adjust offset per track
But I think the docs would benefit from a short note about this in the section where Audacity and ffmpeg are mentioned.
Yeah, they will be totally different. This does an optimised encoding by looking ahead.
We've used it for music in Sparrow Solitaire, and even when we loop we don't notice the small silence.
Thanks for doing this comparison.
I use Fission audio editor on macOS and one of the great things about that is that it edits by block. But, it's still not possible to remove all silence as it's unlikely the music/loop will align exactly on block boundaries. Would love to find out a way to do this!
It might be tricky to remove at the SDK level, eg if someone intentionally wanted silence at the end of a track (I guess could pass a flag?), but at least raising awareness that ADPCM works on a block-based system and can lead to unexpected silence would be nice. Even though it's not Panic's responsibility since it's not like they invented ADPCM, but still.