Delay starting mp3 play

orbitcoms
Posts: 141
Joined: Fri Aug 03, 2018 10:08 pm
Location: Sydney, Australia

Delay starting mp3 play

Postby orbitcoms » Sat Apr 17, 2021 10:11 am

Hi,
I have an issue that playing mp3 files from spiff take about 1 second to start and I need around 100-200ms max.
Someone suggested that the delay may be caused by stopping the pipeline after each play and then having to recreate it. It seems I would need to create the audio pipeline on first start up and not close it down between files being played, but I am not sure how to do this and would really appreciate some help. The code was based on esp example "Play_mp3 using custom board.
I have attached the calling file "audio.c" and the file that creates, plays and shuts down the audio pipeline. (play_spiffs_mp3.c"
Thanks
Attachments
play_spiffs_mp3.c
(7.18 KiB) Downloaded 411 times
audio.c
(4.16 KiB) Downloaded 360 times

chrichri
Posts: 2
Joined: Sat Apr 17, 2021 5:17 pm

Re: Delay starting mp3 play

Postby chrichri » Sat Apr 17, 2021 5:20 pm

Hi, i have the same issue. Did you manage to solve it? :?

orbitcoms
Posts: 141
Joined: Fri Aug 03, 2018 10:08 pm
Location: Sydney, Australia

Re: Delay starting mp3 play

Postby orbitcoms » Mon Apr 19, 2021 8:21 am

No,
had no replies yet.

chrichri
Posts: 2
Joined: Sat Apr 17, 2021 5:17 pm

Re: Delay starting mp3 play

Postby chrichri » Mon Apr 19, 2021 8:54 am

I managed to reduce the delay time by using the lib "esp8266Audio" and a AudioFileSourceBuffer. A buffer has the method "seek" witch can be used to jump to a specific position of the audio data. Hope this might help you.

mairswartz
Posts: 21
Joined: Tue Nov 07, 2017 9:59 pm

Re: Delay starting mp3 play

Postby mairswartz » Mon Apr 19, 2021 10:40 am

Hi guys,
I'm trying to help resolve this for orbitcoms.

If I take https://github.com/espressif/esp-adf/tr ... spiffs_mp3
I notice it takes about 600ms to get to the while loop. Ie the setup code takes some time to run. I tried to split up the code into 3 functions.

init
play
clean


and would like to run the init function only once. and then send different files to the play function however,
I'm having trouble getting it to play the second audio.
if I dont stop the pipe line I get
E (5819) AUDIO_EVT: Error add queue items to queue set
W (5819) AUDIO_PIPELINE: Pipeline already started, state:3
If I do stop it I get
E (9098) AUDIO_ELEMENT: [spiffs] Element already stopped
W (9108) AUDIO_EVT: There is no space in external queue
E (9118) AUDIO_ELEMENT: [mp3] Element already stopped
E (9118) AUDIO_ELEMENT: [volume] Element already stopped
Any guidance on how to initialize the pipeline once or a different way to shave off the time would be appreciated
Attachments
play_spiffs_mp3.c
(8.19 KiB) Downloaded 404 times
check out my course https://learnesp32.com

orbitcoms
Posts: 141
Joined: Fri Aug 03, 2018 10:08 pm
Location: Sydney, Australia

Re: Delay starting mp3 play

Postby orbitcoms » Mon May 03, 2021 10:26 am

I have managed to remove most of the delay (which was linked to how spiffs was being established).

The total time is now 167ms from call until i2S starts streaming out.

The spiffs takes around 1ms, the entire audio element and pipeline setup takes around 26ms

The largest delay is in the function "audio_pipeline_run(pipeline);" This delays 140ms

Does anyone know what has been processed when this function ends? Has the audio file already started being read and decoded ? (Meaning the delay is not a setup delay but now part of the player sequence)?

canbaba
Posts: 2
Joined: Wed Jul 07, 2021 9:38 am

Re: Delay starting mp3 play

Postby canbaba » Wed Jul 07, 2021 9:52 am

Hi, can you give more info for how to solve this problem? You've made a huge improvement.

Congratulations.
orbitcoms wrote:
Mon May 03, 2021 10:26 am
I have managed to remove most of the delay (which was linked to how spiffs was being established).

The total time is now 167ms from call until i2S starts streaming out.

The spiffs takes around 1ms, the entire audio element and pipeline setup takes around 26ms

The largest delay is in the function "audio_pipeline_run(pipeline);" This delays 140ms

Does anyone know what has been processed when this function ends? Has the audio file already started being read and decoded ? (Meaning the delay is not a setup delay but now part of the player sequence)?

Who is online

Users browsing this forum: No registered users and 12 guests