MKR ZERO: Lots of noise and distortion when playing wave files

Hi All,
Have an issue with playing audio from built in SD slot.
Audio is playing with a lot of distortion and noise.

Code almost identical to:

except:
if (!SD.begin(4))
changed to:
if (!SD.begin())

Tried to use wav Files with 44.100 16 bit, 24 bit, 32 bit float
no change

The files are OK playing with Audacity.

Use Output DAC0/A0

Does anybody have a remedy to get it work?

Best regards
ernst

(deleted)

spycatcher2k:
Check your files format! This sounds like you may have these wrong.

:slight_smile:
Big ThanX!
88,2 & 8 bit did the trick!
Well, 8 bit are not much, isn't it?

(deleted)

...I don't know anything about AudioZero.h.

Apparently, it's not reading/parsing the WAV file header because you have to manually key-in the sample rate, and the notes say it has to be an 8-bit file.

If you send the (8-bit) bytes one at a time from a 32-bit file to the DAC you're going to get garbage. :wink:

Well, 8 bit are not much, isn't it?

The chip has a 10-bit DAC so theoretically you could scale-down a 16-bit file. The 8-bit file is most-likely being scaled-up (by the library) for "full loudness" but that doesn't help the resolution.

If you play an 8-bit file on your computer you'll hear quantization noise. The noise "rides on top" of the audio so there is no noise with silence but it's noticeable with quiet sounds. You'll hear it on the MKRzero too, but there may also be other noise. It's easier to compare 8-bit & 16-bit files on the computer. :wink:

8-bit WAV files are unsigned data which means the DAC output is "automatically" biased. The other WAV formats are signed. And and since the DAC can't put-out negative voltages, the bias would have to be added (if you have a library that can play higher bit depths). The DC bias gets removed from the analog by the capacitor at the amplifier input.


When you play a WAV file on your computer the bit-depth is automatically scaled (by the drivers) to match your DAC. That's simply done by multiply by a number larger than 1 to increase the bit depth or by a factor less than 1 to decrease the bit-depth (or it can be done by bit-shifting).

For 8-bit files, 128 is subtracted (to get positive & negative numbers) before scaling. With floating point it's a slightly different because 0dB is represented by a floating-point value of 1.0, but it's still multiplication.

And if the soundcard's clock doesn't support the sample rate, the audio will automatically get resampled to something the soundcard can handle.