Periodic noise when playing a wav file (SD card, Due, DAC, amp and speaker)

Hi Folks, I have been trying to find some more info on this issue but not really turned up any similar examples. Hopefully someone can help.

Setup: I am playing a wav file using a Sainsmart Due, arduino audio library, adafruit audio amp, Lexar SD card and a 4 ohm 3 W speaker.

I’m using DAC0 to output the audio to L+ on the amp. Gnd to L- from as close to DAC0 as possible to keep the noise down. D69 for the shutdown pin on the amp.

**Problem:**When playing back the sound there is a periodic “shh” sound. It is quite short. It appears to match the audio buffer length in the begin command.

In the code below the buffer is set to 100ms and the noise appears to be at 10Hz. If I double the buffer to 200 it is at 5Hz.

It doesn’t seem to be related to the SD card read buffer. I have varied that and it hasn’t impacted it.

The file is a 44kHz mono wav file 21 seconds long.

This is basically the example from the library but using pin 53 for the CS. I added the shutdown pin to confirm that it wasn’t noise after the amp. When it isn’t playing a file the noise goes away.

So my best guess is that the audio library (possibly DAC buffer) isn’t getting filled correctly. It writes it all out, finds the buffer is empty and then has to wait a ms for it to be filled again.

Can anyone else shed any light on this issue? Thanks.


 Demonstrates the use of the Audio library for the Arduino Due

 Hardware required :
 *Arduino shield with a SD card on CS 4 (the Ethernet sheild will work)
 *Audio amplifier circuit with speaker attached to DAC0

 Original by Massimo Banzi September 20, 2012
 Modified by Scott Fitzgerald October 19, 2012


#include <SD.h>
#include <SPI.h>
#include <Audio.h>

int audioShutdownPin = 69;
  int count;
  int volume;
  const int S=2000; // Number of samples to read in block
  short buffer[S];
void setup()
  // debug output at 9600 baud
  digitalWrite(audioShutdownPin,LOW);  //turn off amp.

  // setup SD-card
  Serial.print("Initializing SD card...");
  if (!SD.begin(53)) {
    Serial.println(" failed!");
  Serial.println(" done.");
  // hi-speed SPI transfers

  // 44100Khz stereo => 88200 sample rate
  // 100 mSec of prebuffering.
  Audio.begin(44100, 100);

void loop()
  volume = 50;
  // open wave file from sdcard
  File myFile ="test.wav");
  if (!myFile) {
    // if the file didn't open, print an error and stop
    Serial.println("error opening test.wav");
    while (true);

  // until the file is not finished
  digitalWrite(audioShutdownPin,HIGH);  //turn on amp.
  while (myFile.available()) {
    // read from the file into buffer, sizeof(buffer));

    // Prepare samples
    Audio.prepare(buffer, S, volume);
    // Feed samples to audio
    Audio.write(buffer, S);

    // Every 100 block print a '.'
    if (count == 100) {
     // Serial.print(".");
      count = 0;
      volume = volume + 10;

  Serial.println("End of file. Thank you for listening!");
  digitalWrite(audioShutdownPin,LOW);  //turn off amp.
  while (true) ;