Page 1 of 1

Define aux in (line_in) number

Posted: Wed May 20, 2020 5:59 am
by Gkonoplya
Hello everybody.
I've tried to make running "pipeline_raw_http" example, and it runs as expected, but if I connect my sound source to aux in - it records mics again, and no any input from aux.
I've tried to figure it out, and in my opinion the problem is that codec intitalized for line_in1, and i need to reinitialize it for line_in2.
I think the problem in this code:

Code: Select all

    ESP_LOGI(TAG, "[ 2 ] Start codec chip");
    audio_board_handle_t board_handle = audio_board_init();
    audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_ENCODE, AUDIO_HAL_CTRL_START);
there I need to somehow configure codec to use line_in2.
I've looked for any other exaple, and found it - "pipeline_passthru" - and it works as it should, I can connect to aux_in, and listen in the phone jack, audio from line in. The code for initializing codec is this:

Code: Select all

    ESP_LOGI(TAG, "[ 1 ] Start codec chip");
    audio_board_handle_t board_handle = audio_board_init();
    audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_LINE_IN, AUDIO_HAL_CTRL_START);
First of all, i thout, that main difference in AUDIO_HAL_CODEC_MODE, but changes it in the first example changes nothing :(
All other code seems to be the almost same.
I'm totally stuck. I think that it should be very easy, but I really don't understand what I should to do...
Please, if you have any ideas, give it to me.

UPD:
I've tried to connect headphones to output socket, and it worked as passthru exaple did.
So it seems, that at present moment Lyra-T may works in voice-record mode, or passthru mode, but not in the aux record mode.
((

Re: Define aux in (line_in) number

Posted: Thu May 21, 2020 12:55 pm
by Gkonoplya
After all mindblowing hours and meditation over the code, there is a solution. Thanks to Paul Sykes (https://github.com/paulsykes/esp-adf/tr ... e_passthru)
I don't understand to the last string of code, why it works, but it is.

Code: Select all

    ESP_LOGI(TAG, "[ 2 ] Start codec chip");
    audio_hal_codec_config_t audio_hal_codec_cfg =  AUDIO_CODEC_DEFAULT_CONFIG();
    audio_hal_codec_cfg.adc_input = AUDIO_HAL_ADC_INPUT_LINE2; // 
    audio_hal_codec_cfg.i2s_iface.samples = AUDIO_HAL_48K_SAMPLES; // here put your sampling mode
    audio_hal_handle_t hal = audio_hal_init(&audio_hal_codec_cfg, &AUDIO_CODEC_ES8388_DEFAULT_HANDLE);
    audio_hal_ctrl_codec(hal, AUDIO_HAL_CODEC_MODE_ENCODE, AUDIO_HAL_CTRL_START);
   
This is almost code, that i get by myself, except of i2s_iface.samples. This one works for me - ok.