Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
8605d846
Unverified
Commit
8605d846
authored
Jan 03, 2024
by
Wolle
Committed by
GitHub
Jan 03, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix getAudioCurrentTime()
if resumeFilePos is given in connecttoFS()
parent
905a4fe4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
29 deletions
+15
-29
src/Audio.cpp
src/Audio.cpp
+13
-27
src/Audio.h
src/Audio.h
+2
-2
No files found.
src/Audio.cpp
View file @
8605d846
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*
*
* Created on: Oct 26.2018
* Created on: Oct 26.2018
*
*
* Version 3.0.8
c
* Version 3.0.8
d
* Updated on: Jan 0
2
.2024
* Updated on: Jan 0
3
.2024
* Author: Wolle (schreibfaul1)
* Author: Wolle (schreibfaul1)
*
*
*/
*/
...
@@ -2910,7 +2910,6 @@ void Audio::processLocalFile() {
...
@@ -2910,7 +2910,6 @@ void Audio::processLocalFile() {
FLACDecoderReset
();
FLACDecoderReset
();
}
}
if
(
m_codec
==
CODEC_MP3
)
{
m_resumeFilePos
=
mp3_correctResumeFilePos
(
m_resumeFilePos
);
}
if
(
m_codec
==
CODEC_MP3
)
{
m_resumeFilePos
=
mp3_correctResumeFilePos
(
m_resumeFilePos
);
}
if
(
m_avr_bitrate
)
m_audioCurrentTime
=
((
double
)(
m_resumeFilePos
-
m_audioDataStart
)
/
m_avr_bitrate
)
*
8
;
audiofile
.
seek
(
m_resumeFilePos
);
audiofile
.
seek
(
m_resumeFilePos
);
InBuff
.
resetBuffer
();
InBuff
.
resetBuffer
();
byteCounter
=
m_resumeFilePos
;
byteCounter
=
m_resumeFilePos
;
...
@@ -4339,49 +4338,36 @@ void Audio::compute_audioCurrentTime(int bd) {
...
@@ -4339,49 +4338,36 @@ void Audio::compute_audioCurrentTime(int bd) {
if
(
m_codec
==
CODEC_M4A
)
{
setBitrate
(
AACGetBitrate
());
}
// if not CBR, bitrate can be changed
if
(
m_codec
==
CODEC_M4A
)
{
setBitrate
(
AACGetBitrate
());
}
// if not CBR, bitrate can be changed
if
(
m_codec
==
CODEC_AAC
)
{
setBitrate
(
AACGetBitrate
());
}
// if not CBR, bitrate can be changed
if
(
m_codec
==
CODEC_AAC
)
{
setBitrate
(
AACGetBitrate
());
}
// if not CBR, bitrate can be changed
if
(
m_codec
==
CODEC_FLAC
)
{
setBitrate
(
FLACGetBitRate
());
}
// if not CBR, bitrate can be changed
if
(
m_codec
==
CODEC_FLAC
)
{
setBitrate
(
FLACGetBitRate
());
}
// if not CBR, bitrate can be changed
if
(
!
getBitRate
())
return
;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
(
m_avr_bitrate
==
0
)
{
// first time
if
(
m_avr_bitrate
==
0
)
{
// first time
loop_counter
=
0
;
loop_counter
=
1
;
old_bitrate
=
0
;
old_bitrate
=
0
;
sum_bitrate
=
0
;
sum_bitrate
=
0
;
f_CBR
=
true
;
f_CBR
=
true
;
m_avr_bitrate
=
getBitRate
();
m_avr_bitrate
=
getBitRate
();
old_bitrate
=
getBitRate
();
old_bitrate
=
getBitRate
();
}
}
if
(
!
m_avr_bitrate
)
return
;
if
(
!
getBitRate
()
)
return
;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
(
loop_counter
<
1000
)
loop_counter
++
;
if
((
old_bitrate
!=
getBitRate
())
&&
f_CBR
)
{
if
((
old_bitrate
!=
getBitRate
())
&&
f_CBR
)
{
if
(
audio_info
)
audio_info
(
"VBR recognized, audioFileDuration is estimated"
);
if
(
audio_info
)
audio_info
(
"VBR recognized, audioFileDuration is estimated"
);
f_CBR
=
false
;
// variable bitrate
f_CBR
=
false
;
// variable bitrate
}
}
old_bitrate
=
getBitRate
();
old_bitrate
=
getBitRate
();
if
(
!
f_CBR
)
{
if
(
loop_counter
<
10000
){
// then the bit rate is determined with sufficient precision
if
(
loop_counter
>
20
&&
loop_counter
<
200
)
{
sum_bitrate
+=
getBitRate
();
// if VBR: m_avr_bitrate is average of the first values of m_bitrate
m_avr_bitrate
=
sum_bitrate
/
loop_counter
;
sum_bitrate
+=
getBitRate
();
loop_counter
++
;
m_avr_bitrate
=
sum_bitrate
/
(
loop_counter
-
20
);
if
(
loop_counter
==
199
&&
m_resumeFilePos
>=
0
)
{
m_audioCurrentTime
=
((
getFilePos
()
-
m_audioDataStart
-
inBufferFilled
())
/
m_avr_bitrate
)
*
8
;
// #293
}
}
}
else
{
if
(
loop_counter
==
2
)
{
m_avr_bitrate
=
getBitRate
();
if
(
m_resumeFilePos
>=
0
)
{
// if connecttoFS() is called with resumeFilePos != 0
m_audioCurrentTime
=
((
getFilePos
()
-
m_audioDataStart
-
inBufferFilled
())
/
m_avr_bitrate
)
*
8
;
// #293
}
}
}
}
m_audioCurrentTime
+=
((
float
)
bd
/
m_avr_bitrate
)
*
8
;
m_audioCurrentTime
+=
((
float
)
bd
/
m_avr_bitrate
)
*
8
;
if
(
loop_counter
%
100
==
0
){
m_audioCurrentTime
=
((
float
)(
getFilePos
()
-
m_audioDataStart
-
inBufferFilled
())
/
m_avr_bitrate
)
*
8
;
// #293
}
}
}
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
void
Audio
::
printDecodeError
(
int
r
)
{
void
Audio
::
printDecodeError
(
int
r
)
{
...
...
src/Audio.h
View file @
8605d846
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*
*
* Created on: Oct 28,2018
* Created on: Oct 28,2018
*
*
* Version 3.0.8
c
* Version 3.0.8
d
* Updated on: Jan 0
2
.2024
* Updated on: Jan 0
3
.2024
* Author: Wolle (schreibfaul1)
* Author: Wolle (schreibfaul1)
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment