nivedita velagaleti
/
lab3_musicplayer
music main
Fork of AppBoard_Waveplayer by
Diff: main.cpp
- Revision:
- 10:6eefc37bfa23
- Parent:
- 9:f1aebfbe7e78
- Child:
- 11:e48cb1e38995
diff -r f1aebfbe7e78 -r 6eefc37bfa23 main.cpp --- 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]); +// } + } + +}