Open Combreaker opened 3 weeks ago
Following code set microphone gain for es8388, If you are using right channel you should set to 0..3 bits. please have a try!
static int es8388_set_mic_gain(audio_codec_es8388_t *codec, float db)
{
int gain = (int)db;
int res, gain_n;
gain_n = (int) gain / 3;
gain_n = (gain_n << 4) + gain_n;
res = es8388_write_reg(codec, ES8388_ADCCONTROL1, gain_n); // MIC PGA
return res;
}
Test show that the register setting can change the recorded data signal level
REg 9 set to 0
I (615408) Rec Test: [ * ] Volume set to 0
I (616298) Rec Test: max db:-48
I (617308) Rec Test: max db:-35
I (618308) Rec Test: max db:-67
I (619318) Rec Test: max db:-66
I (620338) Rec Test: max db:-66
I (621338) Rec Test: max db:-67
I (622348) Rec Test: max db:-67
I (623348) Rec Test: max db:-66
I (624358) Rec Test: max db:-67
REg 9 set to 88
I (638358) Rec Test: [ * ] Volume set to 24
I (638468) Rec Test: max db:-20
I (639478) Rec Test: max db:-26
I (640498) Rec Test: max db:-18
I (641498) Rec Test: max db:-48
I (642508) Rec Test: max db:-50
I (643508) Rec Test: max db:-49
I (644518) Rec Test: max db:-49
I (645538) Rec Test: max db:-48
I'm working with an ESP32-Lyrat v4.3 board and use an external mic to record sound. In the documentation for the ES8388 chip, it says to set certain registry values and i did so but it doesn't change the sound of the output file. Is this the right way or are there other ways to configure the mic on a Lyrat board?
void AudioRecorder::start() { this->board_handle = audio_board_init(); audio_hal_ctrl_codec(this->board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_ENCODE, AUDIO_HAL_CTRL_START); audio_hal_set_volume(this->board_handle->audio_hal, 100); //es8388_write_reg(ES8388_ADCCONTROL1, 0b01110111); es8388_write_reg(ES8388_ADCCONTROL10, 0b11111010); es8388_write_reg(ES8388_ADCCONTROL2, ADC_INPUT_LINPUT2_RINPUT2); //es8388_write_reg(ES8388_ADCCONTROL5, 0b00000110); //es8388_write_reg(ES8388_ADCCONTROL8, 0b11000000); //Reg16 - LADCVOL Attenuation //es8388_write_reg(ES8388_ADCCONTROL9, 0b11000000); //Reg17 - RADCVOL Attenuation es8388_write_reg(ES8388_ADCCONTROL14, 0b01011000);
}