diff --git a/yoRadio/data/www/script.js.gz b/yoRadio/data/www/script.js.gz index dd48ad3..e12541b 100644 Binary files a/yoRadio/data/www/script.js.gz and b/yoRadio/data/www/script.js.gz differ diff --git a/yoRadio/src/audioI2S/Audio.cpp b/yoRadio/src/audioI2S/Audio.cpp index e93b9e9..2241f49 100644 --- a/yoRadio/src/audioI2S/Audio.cpp +++ b/yoRadio/src/audioI2S/Audio.cpp @@ -20,7 +20,7 @@ fs::SDFATFS SD_SDFAT; #endif #ifndef DMA_BUFCOUNT -#define DMA_BUFCOUNT 4 +#define DMA_BUFCOUNT 8 #endif //--------------------------------------------------------------------------------------------------------------------- AudioBuffer::AudioBuffer(size_t maxBlockSize) { diff --git a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp index 60d14e6..873bbff 100644 --- a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp +++ b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp @@ -660,7 +660,8 @@ void Audio::processLocalFile() { if(m_controlCounter != 100){ if(m_codec == CODEC_WAV){ // int res = read_WAV_Header(InBuff.getReadPtr(), bytesCanBeRead); - if(audio_progress) audio_progress(0, getFileSize()); + m_audioDataSize = getFileSize(); + if(audio_progress) audio_progress(0, m_audioDataSize); m_controlCounter = 100; eofHeader = true; } @@ -676,7 +677,8 @@ void Audio::processLocalFile() { // int res = read_M4A_Header(InBuff.getReadPtr(), bytesCanBeRead); // if(res >= 0) bytesDecoded = res; // else{ // error, skip header - if(audio_progress) audio_progress(0, getFileSize()); + m_audioDataSize = getFileSize(); + if(audio_progress) audio_progress(0, m_audioDataSize); m_controlCounter = 100; eofHeader = true; // } @@ -694,7 +696,8 @@ void Audio::processLocalFile() { // if(res >= 0) bytesDecoded = res; // else{ // error, skip header // stopSong(); - if(audio_progress) audio_progress(0, getFileSize()); + m_audioDataSize = getFileSize(); + if(audio_progress) audio_progress(0, m_audioDataSize); m_controlCounter = 100; eofHeader = true; // } @@ -1632,6 +1635,8 @@ void Audio::setDefaults(){ m_streamType = ST_NONE; m_codec = CODEC_NONE; m_playlistFormat = FORMAT_NONE; + m_localBitrateSend = false; + m_audioFileDuration = 0; } //------------------------------------------------------------------------------ /** @@ -2485,23 +2490,49 @@ bool Audio::setFilePos(uint32_t pos){ return s; } uint32_t Audio::getAudioFileDuration(){ - return 0; //TODO + if(!audiofile) return 0; + return m_audioFileDuration; } + +const uint16_t l3id012[16] = {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}; +const uint16_t l3id3[16] = {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}; +char brbuf[32]; uint32_t Audio::getAudioCurrentTime(){ - return 0; //TODO - uint16_t MP3Status; - - MP3Status = read_register(SCI_HDAT1); - //Serial.print("SCI_HDAT1\t"); Serial.println(MP3Status, BIN); - Serial.print("LAYER\t"); Serial.println(MP3Status>>1 & 0b11); - Serial.print("ID\t"); Serial.println(MP3Status>>3 & 0b11); - //HDAT0[15:12] bitrate https://cdn-shop.adafruit.com/datasheets/vs1053.pdf - - MP3Status = read_register(SCI_HDAT0); - //Serial.print("SCI_HDAT0\t"); Serial.println(MP3Status, BIN); - Serial.print("BITRATE\t"); Serial.println(MP3Status>>12); - - return 0; //TODO + uint16_t SCIStatus; + uint32_t prev_bitrate = m_avr_bitrate; + if(m_codec == CODEC_MP3){ + SCIStatus=read_register(SCI_HDAT1); + uint8_t layer = SCIStatus>>1 & 0b11; + uint8_t id = SCIStatus>>3 & 0b11; + SCIStatus = read_register(SCI_HDAT0); + if(layer==1){ //layer3 + if(id==3){ + m_avr_bitrate = l3id3[SCIStatus>>12] * 1000; + }else{ + m_avr_bitrate = l3id012[SCIStatus>>12] * 1000; + } + m_localBitrateSend = prev_bitrate==m_avr_bitrate; + if(m_avr_bitrate==0) return 0; + sprintf(brbuf, "%d", m_avr_bitrate); + if(audio_bitrate && !m_localBitrateSend) audio_bitrate(brbuf); + m_localBitrateSend = true; + m_audioFileDuration = 8 * ((float)m_audioDataSize / (m_avr_bitrate)); + return 8 * ((float)getFilePos() / (m_avr_bitrate)); + } + return 0; + } + if(m_codec == CODEC_AAC || m_codec == CODEC_FLAC || m_codec == CODEC_WAV || m_codec == CODEC_M4A){ + SCIStatus=read_register(SCI_HDAT0); + m_avr_bitrate = SCIStatus * 8; + m_localBitrateSend = prev_bitrate==m_avr_bitrate; + if(m_avr_bitrate==0) return 0; + sprintf(brbuf, "%d", m_avr_bitrate); + if(audio_bitrate && !m_localBitrateSend) audio_bitrate(brbuf); + m_localBitrateSend = true; + m_audioFileDuration = 8 * ((float)m_audioDataSize / (m_avr_bitrate)); + return 8 * ((float)getFilePos() / (m_avr_bitrate)); + } + return 0; } //--------------------------------------------------------------------------------------------------------------------- uint32_t Audio::getAudioDataStartPos() { diff --git a/yoRadio/src/audioVS1053/audioVS1053Ex.h b/yoRadio/src/audioVS1053/audioVS1053Ex.h index 4c74c7e..e28ccf1 100644 --- a/yoRadio/src/audioVS1053/audioVS1053Ex.h +++ b/yoRadio/src/audioVS1053/audioVS1053Ex.h @@ -186,7 +186,10 @@ private: uint8_t m_rev=0; // Revision uint8_t m_playlistFormat = 0; // M3U, PLS, ASX size_t m_file_size = 0; // size of the file + uint32_t m_audioFileDuration = 0; size_t m_audioDataSize = 0; // + uint32_t m_avr_bitrate = 0; + bool m_localBitrateSend = true; uint32_t m_audioDataStart = 0; // in bytes int m_id3Size=0; // length id3 tag bool m_f_ssl=false; diff --git a/yoRadio/src/core/options.h b/yoRadio/src/core/options.h index b9d6ab5..d05b63e 100644 --- a/yoRadio/src/core/options.h +++ b/yoRadio/src/core/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define YOVERSION "0.8.883" +#define YOVERSION "0.8.901" /******************************************************* DO NOT EDIT THIS FILE. @@ -58,7 +58,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti /* TFT DISPLAY */ #ifndef TFT_CS - #define TFT_CS 255 + #define TFT_CS 5 #endif #ifndef TFT_RST #define TFT_RST -1 // Or set to -1 and connect to Esp EN pin diff --git a/yoRadio/src/displays/conf/displayST7735_144conf.h b/yoRadio/src/displays/conf/displayST7735_144conf.h index 96644c3..8227c7d 100644 --- a/yoRadio/src/displays/conf/displayST7735_144conf.h +++ b/yoRadio/src/displays/conf/displayST7735_144conf.h @@ -18,7 +18,7 @@ #define bootLogoTop 68 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ -const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 }; +const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 }; const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 26, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 2, 30 }; const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 5000, 2, 30 }; const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 56, 2, WA_LEFT }, 140, true, MAX_WIDTH, 1000, 4, 30 }; diff --git a/yoRadio/src/displays/conf/displayST7735_blackconf.h b/yoRadio/src/displays/conf/displayST7735_blackconf.h index 4a70b08..bc294ae 100644 --- a/yoRadio/src/displays/conf/displayST7735_blackconf.h +++ b/yoRadio/src/displays/conf/displayST7735_blackconf.h @@ -17,7 +17,7 @@ #define bootLogoTop 68 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ -const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 }; +const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 }; const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 26, 1, WA_LEFT }, 140, true, MAX_WIDTH-24, 5000, 3, 30 }; const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 }; const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 56, 2, WA_LEFT }, 140, true, MAX_WIDTH, 1000, 4, 30 }; @@ -50,7 +50,7 @@ const WidgetConfig bootWdtConf PROGMEM = { 0, 90, 1, WA_CENTER }; const ProgressConfig bootPrgConf PROGMEM = { 90, 14, 4 }; /* BANDS */ /* { onebandwidth, onebandheight, bandsHspace, bandsVspace, numofbands, fadespeed } */ -const VUBandsConfig bandsConf PROGMEM = { 12, 50, 2, 1, 10, 3 }; +const VUBandsConfig bandsConf PROGMEM = { 12, 50, 2, 1, 10, 1 }; const BitrateConfig fullbitrateConf PROGMEM = {{DSP_WIDTH-TFT_FRAMEWDT-19, 23, 1, WA_LEFT}, 22 }; /* STRINGS */ diff --git a/yoRadio/src/displays/conf/displayST7735_miniconf.h b/yoRadio/src/displays/conf/displayST7735_miniconf.h index 003ddca..1805516 100644 --- a/yoRadio/src/displays/conf/displayST7735_miniconf.h +++ b/yoRadio/src/displays/conf/displayST7735_miniconf.h @@ -22,7 +22,7 @@ #define bootLogoTop 68 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ -const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 }; +const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 }; const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 19, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 5000, 3, 30 }; //const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 2, 30 }; const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 33, 2, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 }; @@ -54,7 +54,7 @@ const WidgetConfig bootWdtConf PROGMEM = { 0, 50, 1, WA_CENTER }; const ProgressConfig bootPrgConf PROGMEM = { 90, 14, 4 }; /* BANDS */ /* { onebandwidth, onebandheight, bandsHspace, bandsVspace, numofbands, fadespeed } */ -const VUBandsConfig bandsConf PROGMEM = { 12, 48, 2, 1, 8, 3 }; +const VUBandsConfig bandsConf PROGMEM = { 12, 48, 2, 1, 8, 1 }; /* STRINGS */ const char numtxtFmt[] PROGMEM = "%d";