Add SetInputGain(float gain) to AudioCodec (#1252)

This commit is contained in:
Xiaoxia
2025-10-02 09:55:45 +08:00
committed by GitHub
parent 911fee2d85
commit 2fd0ff0b2a
10 changed files with 80 additions and 115 deletions

View File

@@ -14,6 +14,7 @@ Es8311AudioCodec::Es8311AudioCodec(void* i2c_master_handle, i2c_port_t i2c_port,
output_sample_rate_ = output_sample_rate;
pa_pin_ = pa_pin;
pa_inverted_ = pa_inverted;
input_gain_ = 30;
assert(input_sample_rate_ == output_sample_rate_);
CreateDuplexChannels(mclk, bclk, ws, dout, din);
@@ -81,7 +82,7 @@ void Es8311AudioCodec::UpdateDeviceState() {
.mclk_multiple = 0,
};
ESP_ERROR_CHECK(esp_codec_dev_open(dev_, &fs));
ESP_ERROR_CHECK(esp_codec_dev_set_in_gain(dev_, AUDIO_CODEC_DEFAULT_MIC_GAIN));
ESP_ERROR_CHECK(esp_codec_dev_set_in_gain(dev_, input_gain_));
ESP_ERROR_CHECK(esp_codec_dev_set_out_vol(dev_, output_volume_));
} else if (!input_enabled_ && !output_enabled_ && dev_ != nullptr) {
esp_codec_dev_close(dev_);