Tapton school Fido project audio function

Dependencies:   SDFileSystem mbed wave_player_appbd

Fork of AppBoard_Waveplayer by jim hamblen

Revision:
10:744e78ee502c
Parent:
9:f1aebfbe7e78
diff -r f1aebfbe7e78 -r 744e78ee502c main.cpp
--- a/main.cpp	Fri Nov 01 15:30:47 2013 +0000
+++ b/main.cpp	Thu Feb 09 13:59:46 2017 +0000
@@ -1,34 +1,51 @@
 #include "mbed.h"
-#include "USBHostMSD.h"
 #include "wave_player.h"
+#include "SDFileSystem.h"
+
 //mbed Application board waveplayer demo
-//Plays the wave file "sample.wav" on the USB flash drive
-//Outputs to onboard speaker (but at very low volume)
-//and the Audio Out jack for connection to a set of amplified PC speakers (at higher volume)
-//Needs a USB flash drive inserted with the wav file on it to run
+//Plays the wave file "sample.wav" on the SD drive
+//Outputs to p18 analogue out to an audio amp and speaker 
 
+ 
 //Analog Out Jack
 AnalogOut DACout(p18);
 //On Board Speaker
 PwmOut PWMout(p26);
 
+//SD card
+SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
 wave_player waver(&DACout,&PWMout);
 
 int main()
 {
-    USBHostMSD msd("usb");
+   char buffer[20];
     FILE *wave_file;
     //setup PWM hardware for a Class D style audio output
     PWMout.period(1.0/400000.0);
-    printf("\n\n\nHello, wave world!\n");
-    // wait until connected to a USB device
-    while(!msd.connect()) {
-        Thread::wait(500);
-    }
-    //open wav file and play it
-    wave_file=fopen("/usb/sample.wav","r");
+  while(1){
+    led1=1;
+    led2=0;
+    led3=1;
+    led4=0;
+     
+    for (int a=1;a<40; a++){
+    sprintf(buffer,"/sd/voice%d.wav",a);    
+    wave_file=fopen(buffer,"r");
     waver.play(wave_file);
     fclose(wave_file);
-    //end of program
-    while(1) {};
+    if (a%2!=0){
+    led1= !led1;
+    led2= !led2;
+    led3= !led3;
+    led4= !led4;
+     }
+    }
+    
+  }
 }
\ No newline at end of file