Trying to get data from CODEC chip on LYRAT is giving bad data

Jimrux
Posts: 4
Joined: Wed Jan 08, 2020 7:56 pm

Trying to get data from CODEC chip on LYRAT is giving bad data

Postby Jimrux » Thu Jan 23, 2020 1:12 am

I have been struggling with this but having no luck. I have configured the LYRAT to read audio on AUX Line IN and am trying to read it out directly with i2s_read() . The data I am getting however is not what I would expect. For example if I ground the inputs I would expect to get close to zero or at least see a change in the data I am getting between when I feed it a sawtooth signal and when I ground the inputs. I must be configuring something wrong? I am new to the ESP32 ecosystem and ESP-ADF so am probably doing something stupid.The following code snippets show my set up of i2s to read from the ES8388 and the read statement. The data is sending out over UDP. I have only included the i2s configuration as I know UDP is working.

[Codebox]
// get handle
audio_element_handle_t i2s_stream_reader;

ESP_LOGI(TAG, "[ 1 ] Start codec chip");
audio_board_handle_t board_handle = audio_board_init();
//set up AUX as input
audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_ADC_INPUT_LINE2, AUDIO_HAL_CTRL_START);

ESP_LOGI(TAG, "[2.1] Create i2s stream to read audio data from codec chip");
// configure i2S
i2s_set_clk(0, 8000, 24, 1);
i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT();
i2s_cfg.i2s_config.sample_rate = 8000;
i2s_cfg.type = AUDIO_STREAM_READER;
i2s_cfg.i2s_port = 0;
i2s_stream_reader = i2s_stream_init(&i2s_cfg);
i2s_start(0);

size_t bytes_read;
uint32_t test_buffer[128];

while (1) {
// read 24 bit values into 32 bit buffer
int i2sERR = i2s_read(I2S_NUM_0, (void*)test_buffer, 4 * 128, &bytes_read, portMAX_DELAY);
// send out by UDP
int err = sendto(sock, test_buffer, 4 * 128, 0, (struct sockaddr *)&destAddr, sizeof(destAddr));
}[/Codebox]

drewandre
Posts: 5
Joined: Sat Mar 14, 2020 4:28 pm

Re: Trying to get data from CODEC chip on LYRAT is giving bad data

Postby drewandre » Sun Mar 15, 2020 6:59 pm

Any luck here? I'm trying to accomplish the same thing!

Who is online

Users browsing this forum: No registered users and 13 guests