Page 1 of 1

Delay starting mp3 play

Posted: Sat Apr 17, 2021 10:11 am
by orbitcoms
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

Re: Delay starting mp3 play

Posted: Sat Apr 17, 2021 5:20 pm
by chrichri
Hi, i have the same issue. Did you manage to solve it? :?

Re: Delay starting mp3 play

Posted: Mon Apr 19, 2021 8:21 am
by orbitcoms
No,
had no replies yet.

Re: Delay starting mp3 play

Posted: Mon Apr 19, 2021 8:54 am
by chrichri
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.

Re: Delay starting mp3 play

Posted: Mon Apr 19, 2021 10:40 am
by mairswartz
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

Re: Delay starting mp3 play

Posted: Mon May 03, 2021 10:26 am
by orbitcoms
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)?

Re: Delay starting mp3 play

Posted: Wed Jul 07, 2021 9:52 am
by canbaba
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)?