test1
Fork of VS1053 by
Diff: player.cpp
- Revision:
- 3:683fad085072
- Parent:
- 2:a59255e80c0d
--- a/player.cpp Sat Dec 09 15:07:27 2017 +0000 +++ b/player.cpp Sun Dec 10 20:47:02 2017 +0000 @@ -6,17 +6,15 @@ Serial pc(USBTX, USBRX); playerStatetype playerState; ctrlStatetype ctrlState; -static unsigned char fileBuf[32768]; +static unsigned char fileBuf[48000]; unsigned char *bufptr; -char green; - +char karn; char list[20][50]; //song list char data ; -DigitalIn sw_in(USER_BUTTON); - void Player::begin(void) { + DirHandle *dir; struct dirent *ptr; FileHandle *fp; @@ -36,7 +34,7 @@ j=0; while(*byte){ list[i][j++] = *byte++; - green=i; + karn=i; } pc.printf("%2d . %s\r\n", i,list[i++]); //fp->close(); @@ -49,17 +47,14 @@ 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); @@ -73,32 +68,41 @@ printf("Playing %s ...\r\n",file); /* Main playback loop */ - while((bytes = fp->read(fileBuf,32768)) > 0) { - while((bytes = fp->read(fileBuf,32000)) > 0) { + while((bytes = fp->read(fileBuf,48000)) > 0) { + { bufptr = fileBuf; // actual audio data gets sent to VS10xx. while(bytes > 0) { - n = (bytes < 32)?bytes:32; + n = (bytes < 32)?bytes:32; //การสื่อสารระหว่าง sd card มั้ง ถ้าตัดเล่นไม่ได้ vs1053.writeData(bufptr,n); bytes -= n; bufptr += n; } - uint8_t vol = 0x00;//set vlume + + + /* if(pc.readable()) { + data = pc.getc(); + uint8_t vol = 0xff; + vs1053.setVolume(vol); + }*/ + + uint8_t vol = 0x20;//set vlume vs1053.setVolume(vol); //set vlume + if(playerState != PS_PLAY) //stop { fp->close(); vs1053.softReset(); } - } } - } + } } - } + +