 #include <Audio.h>
 
 void setup() {
-  // debug output at 9600 baud
-  Serial.begin(9600);
+  //Start UART @ 115200 baud rate
+  Serial.begin(115200);
 
-  // setup SD-card
+  //Setup SD-card
   Serial.print("Initializing SD card...");
+  //"Start" SD Card
+  //Pin 4 is the CS pin
   if (!SD.begin(4)) {
     Serial.println(" failed!");
     return;


  //Mono: 44100Khz 
  //Stereo: 88200 sample rate
  //300 mSec of prebuffering.
  Audio.begin(1 * 44100, 300);
}

void loop() {
  int count = 0;

  // open wave file from sdcard
  File myFile = SD.open("test.wav");

  const int S = 1024; // Number of samples to read in block
  short buffer[S];

  Serial.println("Playing");
  //Until the file is not finished
  while (myFile.available()) {
    //Read from the file into buffer
    myFile.read(buffer, sizeof(buffer));
    //Prepare samples, save them in the buffer
    //S = Numver of samples
    //1024 = Volume   
    Audio.prepare(buffer, S, 1024);
    //Feed samples to audio, read buffer and write it on the DAC => Sound!!!
    Audio.write(buffer, S);
  }
  
  myFile.close();

  Serial.println("End of file. Thank you for listening!");
  while (true);   //Infinite loop, program stopped!
}
