music main

Dependencies:   USBHost mbed

Fork of AppBoard_Waveplayer by jim hamblen

Files at this revision

API Documentation at this revision

Comitter:
niv17
Date:
Thu Apr 09 20:24:22 2015 +0000
Parent:
9:f1aebfbe7e78
Child:
11:e48cb1e38995
Commit message:
music main;

Changed in this revision

MMA7660.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
wave_player_appbd.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Thu Apr 09 20:24:22 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- a/main.cpp	Fri Nov 01 15:30:47 2013 +0000
+++ b/main.cpp	Thu Apr 09 20:24:22 2015 +0000
@@ -1,6 +1,9 @@
 #include "mbed.h"
 #include "USBHostMSD.h"
 #include "wave_player.h"
+#include "MMA7660.h"
+#include "rtos.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)
@@ -11,24 +14,71 @@
 AnalogOut DACout(p18);
 //On Board Speaker
 PwmOut PWMout(p26);
-
-wave_player waver(&DACout,&PWMout);
-
+int music = 0;
+void readbuf();
+Serial pc(USBTX,USBRX);
+MMA7660 MMA(p28, p27);
+AnalogIn sound(p17);
+PwmOut r (p23);
+PwmOut g (p24);
+PwmOut b (p25);
+ FILE *wave_file;
+ void readbuf(void const *args);
+ unsigned short * waveArray;
+ DigitalIn fire(p14);
+ void changemusic(void const *args);
+ void changecolor(void const *args);
+ int randomval = 0;
+ int start = 0;
+ Ticker fillbuf;
+unsigned short * buf;
+ wave_player waver(&DACout,&PWMout, &waveArray[0]);
 int main()
 {
     USBHostMSD msd("usb");
-    FILE *wave_file;
+   // for(int i = 0; i<256; i++)
+//        { 
+//       waveArray[i] = 0;
+//        }
+    
+    r.period(0.001);
     //setup PWM hardware for a Class D style audio output
     PWMout.period(1.0/400000.0);
-    printf("\n\n\nHello, wave world!\n");
+    printf("\r\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");
-    waver.play(wave_file);
+
+     
+      pc.printf("\r\nenter wavefile\n\n"); 
+      wave_file =  fopen("/usb/sample.wav","r");
+      
+     // waver.set_verbosity(1);
+    Thread thread(readbuf);
+      waver.play(wave_file);
+      
     fclose(wave_file);
-    //end of program
-    while(1) {};
-}
\ No newline at end of file
+       
+       pc.printf("\r\n END OF FILE\n");
+        pc.printf("\r\n\n BUFFER:::\n");
+       
+         
+    
+   while(1);
+   
+}
+void readbuf(void const * args){
+   
+    while(1){
+         wait_ms(11.0);
+   
+    waver.getFIFO(buf);
+    
+    //for(int i = 0; i<256; i++) {
+//       printf("%hu\r\n",buf[i]); 
+//       }
+   }
+    
+}
--- a/wave_player_appbd.lib	Fri Nov 01 15:30:47 2013 +0000
+++ b/wave_player_appbd.lib	Thu Apr 09 20:24:22 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/4180_1/code/wave_player_appbd/#b1cea7afcfd2
+http://developer.mbed.org/users/niv17/code/wave_player_appbd/#b10ea1b38f08