|
3 | 3 | audio.cpp |
4 | 4 |
|
5 | 5 | Created on: Oct 28.2018 */char audioI2SVers[] ="\ |
6 | | - Version 3.4.2l "; |
| 6 | + Version 3.4.2m "; |
7 | 7 | /* Updated on: Sep 08.2025 |
8 | 8 |
|
9 | 9 | Author: Wolle (schreibfaul1) |
@@ -5343,7 +5343,7 @@ int Audio::sendBytes(uint8_t* data, size_t len) { |
5343 | 5343 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
5344 | 5344 | void Audio::calculateAudioTime(uint16_t bytesDecoderIn, uint16_t bytesDecoderOut) { |
5345 | 5345 |
|
5346 | | - if(m_dataMode != AUDIO_LOCALFILE && m_streamType != ST_WEBFILE) return; //guard |
| 5346 | + // if(m_dataMode != AUDIO_LOCALFILE && m_streamType != ST_WEBFILE) return; //guard |
5347 | 5347 |
|
5348 | 5348 | float audioCurrentTime = 0.0; |
5349 | 5349 |
|
@@ -5372,14 +5372,21 @@ void Audio::calculateAudioTime(uint16_t bytesDecoderIn, uint16_t bytesDecoderOut |
5372 | 5372 | audioCurrentTime = (uint32_t)(m_cat.sumBytesIn * 8 / m_cat.nominalBitRate); |
5373 | 5373 | } |
5374 | 5374 | else{ |
5375 | | - m_cat.sumBitRate += ((m_cat.deltaBytesIn * 8000) / delta_t); // we know the time and bytesIn to compute the bitrate |
| 5375 | + double instBitRate = (m_cat.deltaBytesIn * 8000.0) / delta_t; |
5376 | 5376 | m_cat.counter ++; |
5377 | | - m_cat.avrBitRate = m_cat.sumBitRate / m_cat.counter; |
5378 | | - if(m_cat.counter > 5){ // < 5 is too imprecise |
5379 | | - m_avr_bitrate = m_cat.avrBitRate; |
5380 | | - audioCurrentTime = (float)m_cat.sumBytesIn * 8 / m_cat.avrBitRate; |
5381 | | - m_audioFileDuration = round(((float)m_audioDataSize * 8 / m_cat.avrBitRate)); |
| 5377 | + m_cat.avrBitRate += (instBitRate - m_cat.avrBitRate) / m_cat.counter; |
| 5378 | + if((abs(m_cat.avrBitRate- m_cat.oldAvrBitrate < 50)) && !m_cat.avrBitrateStable){ |
| 5379 | + m_cat.brCounter++; |
| 5380 | + if(m_cat.brCounter > 6){ |
| 5381 | + m_cat.avrBitrateStable = m_cat.avrBitRate; |
| 5382 | + info(evt_bitrate, "%i", m_cat.avrBitrateStable); |
| 5383 | + info(evt_info, "estimated bitrate (b/s): %lu", m_cat.avrBitrateStable); |
| 5384 | + } |
5382 | 5385 | } |
| 5386 | + m_avr_bitrate = m_cat.avrBitRate; |
| 5387 | + audioCurrentTime = (float)m_cat.sumBytesIn * 8 / m_cat.avrBitRate; |
| 5388 | + m_audioFileDuration = round(((float)m_audioDataSize * 8 / m_cat.avrBitRate)); |
| 5389 | + m_cat.oldAvrBitrate = m_avr_bitrate; |
5383 | 5390 | } |
5384 | 5391 | m_cat.deltaBytesIn = 0; |
5385 | 5392 | m_audioCurrentTime = round(audioCurrentTime); |
|
0 commit comments