mp3

Files at this revision

API Documentation at this revision

Comitter:
maner1256
Date:
Thu Nov 21 06:28:51 2019 +0000
Parent:
3:94b538ace77a
Commit message:
mp3;

Changed in this revision

player.cpp Show diff for this revision Revisions of this file
--- a/player.cpp	Sun Dec 10 07:14:12 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-#include "player.h"
-#include"SDFileSystem.h"
-
-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
-Serial pc(USBTX, USBRX);
-playerStatetype  playerState;
-static unsigned char fileBuf[32768];
-unsigned char *bufptr;
-char green;
-
-char list[20][50];            //song list
-
-char data ;
-DigitalIn sw_in(USER_BUTTON);
-
-void Player::begin(void)
-{
-    DirHandle *dir;
-    struct dirent *ptr;
-		FileHandle *fp;
-   
-    vs1053.reset();
-    dir = opendir("/sd");
-    printf("\r\n**********playing list**********\r\n");
-    unsigned char i = 0,j=0;
-    while(((ptr = dir->readdir()) != NULL)&&(i <20))
-    {
-        if(strstr(ptr->d_name,".mp3")||strstr(ptr->d_name,".MP3"))
-        {
-							fp =sd.open(ptr->d_name, O_RDONLY);
-							if(fp != NULL) 
-							{
-								char *byte = ptr->d_name;
-                				j=0;
-                				while(*byte){
-                    				list[i][j++]  = *byte++;
-                    				green=i;
-                }
-                pc.printf("%2d . %s\r\n", i,list[i++]);
-				//fp->close();
-							}
-        }
-    }
-		dir->closedir();
-}
-
-
-
-void Player::stop(void){
-    playerState =PS_STOP;
-    }
-    
-
-
-    
-/*  This function plays back an audio file.  */
-void Player::playFile(char *file) {
-    int bytes;        // How many bytes in buffer left
-    char n;
-    
-    playerState = PS_PLAY;
-    
-    vs1053.setFreq(24000000);     //hight speed
-    
-    FileHandle *fp =sd.open(file, O_RDONLY);
-    
-    if(fp == NULL) {
-        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.
-            while(bytes > 0)
-            {
-                n = (bytes < 32)?bytes:32; 
-                vs1053.writeData(bufptr,n);
-                bytes -= n;
-                bufptr += n;
-                
-            }
-            uint8_t vol = 0x00;//set vlume
-            vs1053.setVolume(vol);  //set vlume
-            
-            if(playerState != PS_PLAY)         //stop
-            {
-                fp->close();
-                vs1053.softReset();
-            }
-            	
-				}
-			}
-        }
-    }
-
-}
-