Library to use with SAMD 21 based DAC

Hi all, I am using an Adafruit Itsy Bitsy M0, which has the build in DAC. I am trying to play a small .WAV file from the onboard Flash. Every DAC audio library I find seems to have some problem of incompatibilities, or flat out doesn't seem to work, like the AudioZero library.

I know the hardware is OK, because of the example code for the "SAMD21 Audio Player" by Oscar Uijl - it plays the built in Eurythmics sample.h perfectly, but I'm not sure how to adapt/use this to open a file.

Is anyone using a current audio driver to play .WAV files?

You don't need an audio library to use the SAMD21 DAC, just the analogWrite() function.

What you do need, in order to play .wav files, is a library to open those files (wherever they happen to be stored), read and convert the data to 8 bit biased samples suitable for analogWrite().

For help fixing problems with libraries, post links to the libraries, the code (using code tags) and the details of the problems, including the complete text of error messages.

I have the code to successfully open the .WAV files, but I don't know what to do next. The example with this library works perfectly, but I'm not sure how to use it as it reads the WAV from an array - GitHub - ocrdu/Arduino_SAMD21_Audio_Player: Simple audio player library for SAMD21G-based Arduinos. Sends an array of samples to the DAC on A0, with optional extrapolation aka oversampling. Intended for playing short sound bites without the need for an external audio player.

Include: #include <AudioPlayer.h>

In setup: DACSetup(f, n); for f Hz playback with n times oversampling (n = 1, 2 or 4).

To play audio: playSample(arrayname, arraysize);

Otherwise, most of the libraries I have found to play .WAV files state that they no longer work. e.g. GitHub - hydronics2/SamdAudio: Audio library for Atmel SAMD states " Update... an Adafruit dependency Adafruit_SPIFlash_FatFs.h is not longer available".

GitHub - Gambalunga/Audio_FeatherM0: Audio library for The Adafruit Feather M0 Express using the Atmel SAMD21 DAC - " As at July 2023 this library does not function with the current release of the Adafruit libraries and the core software for the Adafruit Feather M0 Express."

If someone can give me a tip how to take a .WAV file from memory and write it into the right format to send to analogWrite, that would be appreciated.

No, it doesn't. It reads processed audio samples from an array, suitable for sending directly to the DAC with the proper settings.

You can use the free Audacity program to read .wav files and convert them to 8 bit, 16K samples per second audio data, which would then have to be written out to a raw binary file.

Information on the .wav file format here: WAV - Wikipedia

I appreciate the comment but it's not what I am looking for, and I'll keep looking for advice on how to open and play a .WAV

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.