2
Embed:
(wiki syntax)
Show/hide line numbers
player.cpp
00001 //#include "player.h" 00002 //#include"SDFileSystem.h" 00003 //#include "vs10xx.h" 00004 // 00005 //SDFileSystem sd(D11, D12, D13, D9, "sd"); // the pinout on the mbed Cool 00006 //vs10xx vs1053(D11, D12, D13, D6, D7, D2, D8);//mosi,miso,sclk,xcs,xdcs,dreq,xreset 3spi+chip select 00007 //Serial aa(USBTX, USBRX); 00008 //Serial pc(D1, D0); 00009 //playerStatetype playerState; 00010 //static unsigned char fileBuf[48000]; 00011 //unsigned char *bufptr; 00012 //char green; 00013 //uint8_t vol; 00014 //bool startplaysong; 00015 //bool playsong; 00016 //char datainput; 00017 // 00018 //char list[20][50]; //song list 00019 // 00020 //char data ; 00021 //DigitalIn sw_in(USER_BUTTON); 00022 // 00023 //void Player::begin(void) 00024 //{ 00025 // DirHandle *dir; 00026 // struct dirent *ptr; 00027 // FileHandle *fp; 00028 // 00029 // vs1053.reset(); 00030 // dir = opendir("/sd"); 00031 // //printf("\r\n**********playing list**********\r\n"); 00032 // unsigned char i = 0,j=0; 00033 // while(((ptr = dir->readdir()) != NULL)&&(i <20)) 00034 // { 00035 // if(strstr(ptr->d_name,".mp3")||strstr(ptr->d_name,".MP3")) 00036 // { 00037 // fp =sd.open(ptr->d_name, O_RDONLY); 00038 // if(fp != NULL) 00039 // { 00040 // char *byte = ptr->d_name; 00041 // j=0; 00042 // while(*byte){ 00043 // list[i][j++] = *byte++; 00044 // green=i; 00045 // } 00046 // aa.printf("%2d . %s\r\n", i,list[i++]); 00047 // //fp->close(); 00048 // } 00049 // } 00050 // } 00051 // dir->closedir(); 00052 //} 00053 // 00054 // 00055 // 00056 // 00057 // 00058 ///* select file by num. */ 00059 //void Player::selectfile(char n){ 00060 // 00061 // startplaysong=false; 00062 // playerState =PS_STOP; 00063 // playsong=false; 00064 // green = n; 00065 // } 00066 // 00067 // 00068 // 00069 ///* This function stop an audio file. */ 00070 //void Player::stop(void){ 00071 // startplaysong=true; 00072 // playerState =PS_STOP; 00073 // } 00074 // 00075 // 00076 //void Player::run(){ 00077 //// vs1053.setVolume(t); 00078 // if(datainput=='0'){ 00079 // selectfile(0); 00080 // playFile(list[green]); 00081 // //stop(); 00082 // } 00083 // if(datainput=='1'){ 00084 // selectfile(1); 00085 // playFile(list[green]); 00086 // //stop(); 00087 // 00088 // } 00089 // if(datainput=='2'){ 00090 // selectfile(2); 00091 // playFile(list[green]); 00092 // //stop(); 00093 // } 00094 // if(datainput=='3'){ 00095 // selectfile(3); 00096 // playFile(list[green]); 00097 // //stop(); 00098 // } 00099 // if(datainput=='4'){ 00100 // selectfile(4); 00101 // playFile(list[green]); 00102 // //stop(); 00103 // } 00104 // if(datainput=='5'){ 00105 // selectfile(5); 00106 // playFile(list[green]); 00107 // //stop(); 00108 // } 00109 // else{ 00110 // stop(); 00111 // } 00112 //} 00113 // 00114 // 00115 // 00116 //void Player::read(void){ 00117 // pc.readable(); 00118 // datainput = pc.getc(); 00119 // 00120 // } 00121 // 00122 // 00123 ///* This function plays audio file. */ 00124 //void Player::playFile(char *file) { 00125 // int bytes; // How many bytes in buffer left 00126 // char n; 00127 // 00128 // playerState = PS_PLAY; 00129 // 00130 // vs1053.setFreq(24000000); //hight speed 00131 // 00132 // FileHandle *fp =sd.open(file, O_RDONLY); 00133 // 00134 // if(fp == NULL) { 00135 // printf("Could not open %s\r\n",file); 00136 // 00137 // } 00138 // else 00139 // { 00140 // printf("Playing %s ...\r\n",file); 00141 // 00142 // /* Main playback loop */ 00143 // while((bytes = fp->read(fileBuf,48000)) > 0) { 00144 // { 00145 // //pc.printf("green\n"); 00146 // if(pc.readable()){ 00147 // break; 00148 // //stop(); 00149 // } 00150 // vs1053.setFreq(24000000); 00151 // bufptr = fileBuf; 00152 // // actual audio data gets sent to VS10xx. 00153 // while(bytes > 0) 00154 // { 00155 // n = (bytes < 32)?bytes:32; //defalt 32 00156 // vs1053.writeData(bufptr,n); 00157 // bytes -= n; 00158 // bufptr += n; 00159 // if(pc.readable()){ 00160 // break; 00161 // //stop(); 00162 // } 00163 // 00164 // } 00165 // uint8_t vol = 0;//set vlume 00166 // vs1053.setVolume(vol); //set vlume 00167 // 00168 // 00169 // if(playerState != PS_PLAY) //stop 00170 // { 00171 // fp->close(); 00172 // vs1053.softReset(); 00173 // } 00174 // 00175 // } 00176 // } 00177 // } 00178 // 00179 //} 00180 //
Generated on Sun Jul 17 2022 01:45:49 by
1.7.2