ADPCM files played in reverse crashes the simulator on Mac

Hi,
If I try to play an adpcm .wav file in reverse (with a negative setRate of the sampleplayer), then sometimes the simulator will crash on macOS.
I cannot test on device.
With an .aiff file (signed 16bits PCM) I don't have the problem.

Perhaps related, I'm getting that crashee of Simulator and Device with audio files (MP3, for me)

Oops. Looks like I accidentally removed the rate < 0 check in ADPCM playback when I refactored that code recently. :frowning: Since ADPCM is block based we'd have to change the decoder so it decodes and caches whole blocks at a time in order to scan samples in reverse. Not impossible, but it'll be a fair bit of work.

If reverse ADPCM playback isn't supported would you expect it to throw an error, or just not play?

Thank you, I'll continue using the aiff file then :slight_smile:
My audio file it not that long, so the filesize overhead is not a big problem.

I believe it could make sense to just go the nearest supported rate (0, in our case) if the given rate is not supported, but I have no real preferences.

I thought that the Sample Player was decoding all the audio in memory (and thus could play backwards), while the File Player could not.

You might want to update the doc to reflect the special cases.

Here is the current doc:

playdate.sound.sampleplayer:setRate(rate)
Sets the playback rate for the sample. 1.0 is normal speed, 0.5 is down an octave, 2.0 is up an octave, etc. Sampleplayers can also play samples backwards, by setting a negative rate.

playdate.sound.fileplayer:setRate(rate)
Sets the playback rate for the file. 1.0 is normal speed, 0.5 is down an octave, 2.0 is up an octave, etc. Unlike sampleplayers, fileplayers can’t play in reverse (i.e., rate < 0).

ah, right! that's what it was--we originally decoded the entire ADPCM to raw PCM at load time, so it worked exactly the same as uncompressed audio files and negative rates worked fine. A while back I changed that so it decodes on the fly to save memory and that's where I forgot to do the rate check.

I've filed that, not sure yet whether I'll have it throw an error or just stop playing, but I'll definitely point this out in the docs either way. Thanks for catching this!

1 Like

Hi,
With the ADPCM .wav files not being able to be played in reverse using the sampleplayer, what is the recommended audio file format if we want to play it in reverse, and have a balance of good performance and small file size ?