Page 1 of 1

Simple loopback i2s full duplex how

Posted: Wed Aug 29, 2018 11:05 am
by oggettone
Hello, I'm trying to play with pipelines on esp-adf, I've just tried to test a loopback pipeline i2s reader --> i2s writer to play what very same input to the output.

Here my snippet, I've probably did something wrong, in the monitor I saw "W (367) I2S: I2S driver already installed" when I'll add the second i2s_cfg_r, from docs it is not clear how to use i2s in full duplex:

ESP_LOGI(TAG, "[3.0] Create audio pipeline for loopback");
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pipeline = audio_pipeline_init(&pipeline_cfg);
mem_assert(pipeline);

ESP_LOGI(TAG, "[3.1] Create i2s stream to write data to codec chip");
i2s_stream_cfg_t i2s_cfg_w = I2S_STREAM_CFG_DEFAULT();
i2s_cfg_w.type = AUDIO_STREAM_WRITER;
i2s_stream_writer = i2s_stream_init(&i2s_cfg_w);

ESP_LOGI(TAG, "[3.2] Create i2s stream to read audio data from codec chip");
i2s_stream_cfg_t i2s_cfg_r = I2S_STREAM_CFG_DEFAULT();
i2s_cfg_r.type = AUDIO_STREAM_READER;
i2s_stream_reader = i2s_stream_init(&i2s_cfg_r);

ESP_LOGI(TAG, "[3.3] Register all elements to audio pipeline");
audio_pipeline_register(pipeline, i2s_stream_writer, "i2s_w");
audio_pipeline_register(pipeline, i2s_stream_reader, "i2s_r");

ESP_LOGI(TAG, "[3.4] Link it together [codec_chip]-->i2s_stream_r->i2s_stream_w-->[codec_chip]");
audio_pipeline_link(pipeline, (const char *[]) {"i2s_r", "i2s_w"}, 2);

i2s_stream_set_clk(i2s_stream_reader, 16000, 16, 2);
i2s_stream_set_clk(i2s_stream_writer, 16000, 16, 2);

Ultimately I would like to test the following pipeline "read i2s" -> "write on UPD socket"->"write i2s the very same input", I guess I need to create my audio element stream that supports UDP I thought to start from http_stream example or raw_stream and write my own (BTW is this the right things to do?), but without knowing how to use i2s in full duplex it I'm stuck.

Anyone tried that?