Go Down

Topic: simple audio player on the SAMD21 (Read 689 times) previous topic - next topic


I've started to tinker with the samd21 chips...

This Arduino library for the Zero produces scratchy telephone quality playback. It sends 8bit sound to the 10bit DAC via this SD card library

Adafruit's circuit python actually sounds pretty decent playing 16bit audio from the same chip, QUAD SPI flash, to the 10bit DAC. hookup guide

Any ideas for porting a simple flash or SD audio player to Arduinoland? I have a couple flash memory chips ready to test but no library for DAC output with perhaps DMA support!?

teensy of course does it so well. I highly recommend teensy for powerful, inexpensive  audio projects! I started to dig into PJRC's libraries to see if there was a way to port a simple player to SAMD21 and quickly got lost.  Should I pursue that route?


Hello Hydronics,

You might want to give this a try: https://github.com/BriscoeTech/SamdAudio

I forked a library originally from AloyseTech that allows you to play sounds straight from an SD card. What is nice about the library is the commands are non blocking and interrupt driven. Also, you can play up to four channels of sound simultaneously. Im using it with FreeRots for my laser tag guns project and it works very well. I think its worth giving it a try before you go and develop a new library from scratch.

Hope this helps!


Great, thanks for the link. I had to change a variable in the library for it to work... otherwise it would freeze in configureReaderTimer()...

changed GCLK_SRC from 5 to 0 but 1 & 3 also worked on the Adafruit M0 board.

Code: [Select]
void SamdAudio::configureReaderTimer()
    // The GCLK clock provider to use  ...GCLK0, GCLK1, GCLK3, GCLK5
    // 0,1 & 3 worked on the Adafruit M0. GCLK5 did not work
    const uint8_t GCLK_SRC = 0;


Hmm thats strange, iv used this library on a adafruit feather adalogger and didn't run into any issues.

Was it freezing just running the basic example, or when you started developing your own project?


oh my gosh! I worked and worked but didn't dig to deep on it...

I think GCLK5 could be used by Adafruit's QUAD flash  chip? I also found that GCLK0 seems to be used by serial so I landed on GCLK1 as a good bet.

I forked your github and added support for the QUAD flash chip on the Adafruit Express Boards:


Medium quality output 8bit and up to 44.1khz if using QUAD SPI flash on the Adafruit M0 boards. Reduced quality ~22khz using an SD card.

It all sound fairly marginal at 8bit. Until we get 16bit DMA output going on the SAMD21, for good sound quality, I recommend going with a Teensy or a peripherial codec to do the heavy lifting.

This library plays WAV files stored on the SPI Flash Adafruit includes on their Express boards. This includes:

  • Itsybits M0 Express (tested)
  • Trinket M0 Express (have board will test)
  • ItsyBitsy M4 Express
  • Feather M0 Express

Go Up