New library for PWM playback from SD cards: SimpleSDAudio

hello Tuttut

i just finished an analysis of pwm distortion, and then thought it would be cool to make a good and cheap wav player. and it turns out it is cool, and you have already done it. thanks for the work, i always enjoy finding projects like this. if you are open to suggestions, here are some things that my research has shown to make improvements in the audio quality.

  1. use 14b, phase correct pwm, at 62khz clock rate. you never really get the full 16b anyways, even with perfect resistors, due to distortions building up in the noise floor. also, perfect resistors are difficult to come by, even with trimming, due to the variability of the internal resistance of the arduino.

  2. use 3.9k / 499k resistors for the mixing. the output resistance is around 40ohms, so this keeps its error component low in comparison to the 3.9k.

  3. dont bother with the external logic chips, they have a lot of jitter in comparison to the arduino itself, and introduce phase modulation and associated distortions. also, the noise floor on the arduino i tested was -110dB, which was below the pwm noise floor for frequencies above 1kHz. with the usb disconnected, the arduino isnt that bad.

  4. you can try changing the depth / location of pwm to get further gains, but its probably not too significant for audio (as compared to pure tones), as the maximum amplitude is usually low anyways.

here are the writeups if youre interested:

distortion analysis:

dual pwms:

again, great work, im looking forward to trying it out.