How to handle the latency in the multi room example ?

Issylin
Posts: 2
Joined: Sat Apr 02, 2022 1:35 pm

How to handle the latency in the multi room example ?

Postby Issylin » Sat Apr 02, 2022 2:06 pm

Hi all,

I'm new to the ESP32 world, and I'm currently discovering on linux the multi-room example which can be found here : https://github.com/espressif/esp-adf/tr ... multi-room.

Building and flashing on 2 ESP32 LyraT boards worked fine. The latency displayed on the terminal of the master board seemed correct to me being given it was between +/- 1ms and +/- 17ms. Furthermore, it was perfectly working according to the readme.

However, when I used a 3rd ESP32 LyraT board as a 2nd slave, the latency shown was around +/-200ms.
I don't think it is a connexion issue from the wifi source, it'd had been to easy, so I dove into the different pipelines used to convey the data.
Here are the two which seemed particularly important to me, especially the raw stream one :
https://docs.espressif.com/projects/esp ... ream_cfg_t
https://docs.espressif.com/projects/esp ... ream_cfg_t

The main file of the multi-room example is located here : https://github.com/espressif/esp-adf/bl ... lti_room.c. In this example, the two pipelines above are intialized in the setup_player function (line 155).
As we can see in this function, there are many output ringbuffers named out_rb_size. The values 100 * 1024 and 50 * 1024 seemed to be the default ones as shown below.

From the line 181 :

Code: Select all

http_stream_cfg_t http_cfg = HTTP_STREAM_CFG_DEFAULT();
http_cfg.task_stack = 0;
http_cfg.out_rb_size = 100 * 1024;
http_stream_reader = http_stream_init(&http_cfg);

raw_stream_cfg_t raw_reader = RAW_STREAM_CFG_DEFAULT();
raw_reader.type = AUDIO_STREAM_READER;
raw_reader.out_rb_size = 100 * 1024;
player_raw_in_h = raw_stream_init(&raw_reader);
esp_audio_input_stream_add(player, player_raw_in_h);

audio_decoder_t auto_decode[] = { /* some stuff */ };

esp_decoder_cfg_t auto_dec_cfg = DEFAULT_ESP_DECODER_CONFIG();
auto_dec_cfg.out_rb_size = 50 * 1024;
esp_audio_codec_lib_add(player, AUDIO_CODEC_TYPE_DECODER, esp_decoder_init(&auto_dec_cfg, auto_decode, 10));
Question : Can the sizes of the output ringbuffers have an impact on the latency observed and heard ? If so, could you please explain me the good way to calculate them in accordance to the number of ESP32 slave boards playing the same music together ?
Obviously, if I'm searching in the total wrong direction, please enlighten me how to do it well with some links (if you're tired of writing all the details :p ).

Thanks everyone

Who is online

Users browsing this forum: No registered users and 38 guests