sxa

Dependents:   MP3333 B18_MP3_PLAYER B18_MP3_PLAYER B18_MP3_PLAYER

Revision:
2:6f21eae5f456
Parent:
1:4afda9d22e34
Child:
3:934d5e72990a
--- a/player.cpp	Mon Dec 07 12:17:51 2015 +0000
+++ b/player.cpp	Tue Dec 08 19:52:11 2015 +0000
@@ -1,12 +1,12 @@
 #include "player.h"
 #include "SDFileSystem.h"
 
-SDFileSystem sd(D11, D12, D13, D10, "sd"); // the pinout on the mbed Cool
-vs10xx vs1053(D11, D12, D13, A4, A3, A5, A2);//mosi,miso,sclk,xcs,xdcs,dreq,xreset
+SDFileSystem sd(D11, D12, D13, D9, "sd"); // the pinout on the mbed Cool
+vs10xx vs1053(D11, D12, D13, D6, D7, D2, D8 );//mosi,miso,sclk,xcs,xdcs,dreq,xreset
 
 playerStatetype  playerState;
 ctrlStatetype ctrlState;
-static unsigned char fileBuf[32768];
+static unsigned char fileBuf[65536];
 unsigned char *bufptr;
 
 char list[20][50];          //song list
@@ -58,10 +58,9 @@
         printf("Could not open %s\r\n",file);
 
     } else {
-        printf("Playing %s ...\r\n",file);
 
         /* Main playback loop */
-        while((bytes = fp->read(fileBuf,32768)) > 0) {
+        while((bytes = fp->read(fileBuf,32000)) > 0) {
             bufptr = fileBuf;
 
             // actual audio data gets sent to VS10xx.
@@ -70,25 +69,13 @@
                 vs1053.writeData(bufptr,n);
                 bytes -= n;
                 bufptr += n;
+                if(playerState == PS_STOP)break;
+                while(playerState == PS_PAUSE);
             }
+            if(playerState == PS_STOP)break;
         }
-        /*while(playerState == PS_PAUSE);         //Pause
-
-        if(vlumeflag) {                        //set vlume
-            vs1053.setFreq(12000000);     //low speed
-            vs1053.writeRegister(SPI_VOL, vlume*0x101);     //Set volume level
-            vs1053.setFreq(24000000);     //higth speed
-            vlumeflag = 0;  //clear flag;
-        }
-
-        if(playerState != PS_PLAY) {       //stop
-            fp->close();
-            vs1053.softReset();
-            return;
-        }*/
         fp->close();
         vs1053.softReset();
-        printf("[done!]\r\n");
     }
     if(index != index_MAX)index++;
     else index = 0;