vc_sdfile_current_time

This commit is contained in:
e2002
2022-12-28 13:06:29 +03:00
parent 44e367a75e
commit d611d44eee
8 changed files with 60 additions and 26 deletions

Binary file not shown.

View File

@@ -20,7 +20,7 @@
fs::SDFATFS SD_SDFAT; fs::SDFATFS SD_SDFAT;
#endif #endif
#ifndef DMA_BUFCOUNT #ifndef DMA_BUFCOUNT
#define DMA_BUFCOUNT 4 #define DMA_BUFCOUNT 8
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
AudioBuffer::AudioBuffer(size_t maxBlockSize) { AudioBuffer::AudioBuffer(size_t maxBlockSize) {

View File

@@ -660,7 +660,8 @@ void Audio::processLocalFile() {
if(m_controlCounter != 100){ if(m_controlCounter != 100){
if(m_codec == CODEC_WAV){ if(m_codec == CODEC_WAV){
// int res = read_WAV_Header(InBuff.getReadPtr(), bytesCanBeRead); // 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; m_controlCounter = 100;
eofHeader = true; eofHeader = true;
} }
@@ -676,7 +677,8 @@ void Audio::processLocalFile() {
// int res = read_M4A_Header(InBuff.getReadPtr(), bytesCanBeRead); // int res = read_M4A_Header(InBuff.getReadPtr(), bytesCanBeRead);
// if(res >= 0) bytesDecoded = res; // if(res >= 0) bytesDecoded = res;
// else{ // error, skip header // 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; m_controlCounter = 100;
eofHeader = true; eofHeader = true;
// } // }
@@ -694,7 +696,8 @@ void Audio::processLocalFile() {
// if(res >= 0) bytesDecoded = res; // if(res >= 0) bytesDecoded = res;
// else{ // error, skip header // else{ // error, skip header
// stopSong(); // stopSong();
if(audio_progress) audio_progress(0, getFileSize()); m_audioDataSize = getFileSize();
if(audio_progress) audio_progress(0, m_audioDataSize);
m_controlCounter = 100; m_controlCounter = 100;
eofHeader = true; eofHeader = true;
// } // }
@@ -1632,6 +1635,8 @@ void Audio::setDefaults(){
m_streamType = ST_NONE; m_streamType = ST_NONE;
m_codec = CODEC_NONE; m_codec = CODEC_NONE;
m_playlistFormat = FORMAT_NONE; m_playlistFormat = FORMAT_NONE;
m_localBitrateSend = false;
m_audioFileDuration = 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
@@ -2485,23 +2490,49 @@ bool Audio::setFilePos(uint32_t pos){
return s; return s;
} }
uint32_t Audio::getAudioFileDuration(){ 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(){ uint32_t Audio::getAudioCurrentTime(){
return 0; //TODO uint16_t SCIStatus;
uint16_t MP3Status; uint32_t prev_bitrate = m_avr_bitrate;
if(m_codec == CODEC_MP3){
MP3Status = read_register(SCI_HDAT1); SCIStatus=read_register(SCI_HDAT1);
//Serial.print("SCI_HDAT1\t"); Serial.println(MP3Status, BIN); uint8_t layer = SCIStatus>>1 & 0b11;
Serial.print("LAYER\t"); Serial.println(MP3Status>>1 & 0b11); uint8_t id = SCIStatus>>3 & 0b11;
Serial.print("ID\t"); Serial.println(MP3Status>>3 & 0b11); SCIStatus = read_register(SCI_HDAT0);
//HDAT0[15:12] bitrate https://cdn-shop.adafruit.com/datasheets/vs1053.pdf if(layer==1){ //layer3
if(id==3){
MP3Status = read_register(SCI_HDAT0); m_avr_bitrate = l3id3[SCIStatus>>12] * 1000;
//Serial.print("SCI_HDAT0\t"); Serial.println(MP3Status, BIN); }else{
Serial.print("BITRATE\t"); Serial.println(MP3Status>>12); m_avr_bitrate = l3id012[SCIStatus>>12] * 1000;
}
return 0; //TODO 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() { uint32_t Audio::getAudioDataStartPos() {

View File

@@ -186,7 +186,10 @@ private:
uint8_t m_rev=0; // Revision uint8_t m_rev=0; // Revision
uint8_t m_playlistFormat = 0; // M3U, PLS, ASX uint8_t m_playlistFormat = 0; // M3U, PLS, ASX
size_t m_file_size = 0; // size of the file size_t m_file_size = 0; // size of the file
uint32_t m_audioFileDuration = 0;
size_t m_audioDataSize = 0; // size_t m_audioDataSize = 0; //
uint32_t m_avr_bitrate = 0;
bool m_localBitrateSend = true;
uint32_t m_audioDataStart = 0; // in bytes uint32_t m_audioDataStart = 0; // in bytes
int m_id3Size=0; // length id3 tag int m_id3Size=0; // length id3 tag
bool m_f_ssl=false; bool m_f_ssl=false;

View File

@@ -1,7 +1,7 @@
#ifndef options_h #ifndef options_h
#define options_h #define options_h
#define YOVERSION "0.8.883" #define YOVERSION "0.8.901"
/******************************************************* /*******************************************************
DO NOT EDIT THIS FILE. DO NOT EDIT THIS FILE.
@@ -58,7 +58,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
/* TFT DISPLAY */ /* TFT DISPLAY */
#ifndef TFT_CS #ifndef TFT_CS
#define TFT_CS 255 #define TFT_CS 5
#endif #endif
#ifndef TFT_RST #ifndef TFT_RST
#define TFT_RST -1 // Or set to -1 and connect to Esp EN pin #define TFT_RST -1 // Or set to -1 and connect to Esp EN pin

View File

@@ -18,7 +18,7 @@
#define bootLogoTop 68 #define bootLogoTop 68
/* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ /* 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 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 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 }; const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 56, 2, WA_LEFT }, 140, true, MAX_WIDTH, 1000, 4, 30 };

View File

@@ -17,7 +17,7 @@
#define bootLogoTop 68 #define bootLogoTop 68
/* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ /* 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 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 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 }; 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 }; const ProgressConfig bootPrgConf PROGMEM = { 90, 14, 4 };
/* BANDS */ /* { onebandwidth, onebandheight, bandsHspace, bandsVspace, numofbands, fadespeed } */ /* 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 }; const BitrateConfig fullbitrateConf PROGMEM = {{DSP_WIDTH-TFT_FRAMEWDT-19, 23, 1, WA_LEFT}, 22 };
/* STRINGS */ /* STRINGS */

View File

@@ -22,7 +22,7 @@
#define bootLogoTop 68 #define bootLogoTop 68
/* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ /* 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 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 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 }; 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 }; const ProgressConfig bootPrgConf PROGMEM = { 90, 14, 4 };
/* BANDS */ /* { onebandwidth, onebandheight, bandsHspace, bandsVspace, numofbands, fadespeed } */ /* 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 */ /* STRINGS */
const char numtxtFmt[] PROGMEM = "%d"; const char numtxtFmt[] PROGMEM = "%d";