Has anyone been able to modify the Simple Audio Player sketch so that playback can happen without pausing other operations in the loop code for the Due board? I'm not sure whether it's the buffer that's causing the pause or the Audio.write command, but I added a blinking light line of code in and when I press the button I've assigned to play my audio file, the light completely stops until the audio is done playing. I'm hoping there is a way to perform an audio playback on both DACs as well as run the regular loop code simultaneously. Shouldn't be too hard since it's pushing analog signals from a buffer, but I'm lost... Here's my test code.

void setup(){pinMode(5,OUTPUT); //this is the LED outputdigitalWrite(5,ledstate);pinMode(7,INPUT); //this is the button input, I just run a 10k resistor to GND to activate the sounddigitalWrite(7,HIGH); //internal pullup to apply a high voltage to the pin so we can pull it low to activate

SPI.setClockDivider(4); Audio.begin(12800, 100); //my wav file was recorded at a slower bit rate}

Another thing I will note is that the first playback of the audio sounds good, but playing the audio after that sounds very scratchy for some reason... I have absolutely no clue why unless i should clear my buffer or something...

Does anybody know if it is possible to play two files parallel (by using both DACs and reading from the SD card alternating)? The Audio library says that it writes the audio signal to DAC0 and DAC1, but actually only DAC0 is used, right?

This might be a bit off topic, but you may be interested in an alternate audio library I've been writing for Teensy. It's still at a fairly early stage of development. A major feature (which does work well) is playback in the background. In fact, this new library lets you create many audio objects, interconnected in arbitrary ways, with automatic audio data flow between them, all updated in the background. For example, you can create 3 wav file players, connect them to the inputs of a 4 channel mixer, and then connect the mixer to the DAC output, or an audio shield output, or both.

Unfortunately, this new library requires different hardware. While the audio processing objects are relatively pure software, all the input & output objects are coded for the DMA hardware on Freescale's chip. The library also makes heavy use of the Cortex-M4 special DSP accelerating instructions, which dramatically speed up some objects like the FFT, BiQuad filters, and waveform synthesis.

@Paul This sounds absolutely perfect. I think this is something many people could use for projects. Sometimes I think of something like an "operating system" which combines many tasks in one library, where you can add buttons which are already debounced, 7 Segments, Displays, Audio ^^ and so on ... like a simple LabView for Arduino

but I bought a DUE, because I thought there would be more libraries to handle this. But actually there are very little tutorials and libraries for the DUE available compared to the UNO.

But I think I have an idea to write my own program for playing two WAV files from the SD card. The idea is to use this timer library https://github.com/ivanseidel/DueTimer and create two timers that read the WAV (starting from byte 44) at the given sample rate and then write it to the DAC0 and DAC1. That should do everything I need.

But I'm still thinking about what happens if two timers are used. Will they called both one after the other with the given frequency? What if other Input interrupts (Buttons and Hall Sensors will also be used) are coming in?