Windows Simulator: occasional audio distortion when audio device isn't 44.1khz

I've noticed minor audio clipping/distortion when playing back music in the Windows simulator. This doesn't seem to occur on the macOS simulator. The clipping only seems to occur when the audio output device in Windows is set to a sample rate other than 44,100 Hz (it usually seems to default to 48,000 Hz). I've noticed the behavior both when playing a 16-bit 44.1khz .wav file through playdate.sound.fileplayer, and when directly passing samples to playdate->sound->addSource() in the C API.

I've included in demo.zip (2.3 MB) the first 15 seconds of an affected song as a .wav file, as well as a main.lua file that plays the clip using fileplayer.

  1. Unzip demo.zip, then compile the demo with pdc.exe demo.
  2. Make sure your default audio device is set to a sample rate other than 44,100 Hz (e.g. 48,000 Hz).
  3. Run demo.pdx in the Simulator, then compare the result to the included .wav file. You should hear a quiet clicking or buzzing noise.

I'm on Windows 11 22H2. Let me know if you have trouble reproducing this, or have any other questions.