forked from xiaozhi/xiaozhi-esp32
正点原子esp32s3开发板音量问题修正 (#125)
* Update config.h 添加音量增益设置 * Update config.h 音量增益设置 * Update atk_dnesp32s3.cc 音量增益设置 * Update es8388_audio_codec.h 音量增益设置 * Update es8388_audio_codec.cc 音量增益设置
This commit is contained in:
@@ -194,4 +194,12 @@ int Es8388AudioCodec::Write(const int16_t* data, int samples) {
|
|||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_codec_dev_write(output_dev_, (void*)data, samples * sizeof(int16_t)));
|
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_codec_dev_write(output_dev_, (void*)data, samples * sizeof(int16_t)));
|
||||||
}
|
}
|
||||||
return samples;
|
return samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Es8388AudioCodec::WriteReg(uint8_t reg_addr, uint8_t data) {
|
||||||
|
if (ctrl_if_ != nullptr) {
|
||||||
|
ctrl_if_->write_reg(ctrl_if_, reg_addr, 1, &data, 1);
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(TAG, "Control interface is not initialized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public:
|
|||||||
virtual void SetOutputVolume(int volume) override;
|
virtual void SetOutputVolume(int volume) override;
|
||||||
virtual void EnableInput(bool enable) override;
|
virtual void EnableInput(bool enable) override;
|
||||||
virtual void EnableOutput(bool enable) override;
|
virtual void EnableOutput(bool enable) override;
|
||||||
|
|
||||||
|
void WriteReg(uint8_t reg_addr, uint8_t data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _ES8388_AUDIO_CODEC_H
|
#endif // _ES8388_AUDIO_CODEC_H
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ public:
|
|||||||
GPIO_NUM_NC, AUDIO_CODEC_ES8388_ADDR);
|
GPIO_NUM_NC, AUDIO_CODEC_ES8388_ADDR);
|
||||||
|
|
||||||
audio_codec->SetOutputVolume(AUDIO_DEFAULT_OUTPUT_VOLUME); //设置默认音量
|
audio_codec->SetOutputVolume(AUDIO_DEFAULT_OUTPUT_VOLUME); //设置默认音量
|
||||||
|
audio_codec->WriteReg(0x30, AUDIO_ADD_OUTPUT_VOLUME);
|
||||||
|
audio_codec->WriteReg(0x31, AUDIO_ADD_OUTPUT_VOLUME);//音量增益设置
|
||||||
}
|
}
|
||||||
return audio_codec;
|
return audio_codec;
|
||||||
}
|
}
|
||||||
@@ -178,4 +180,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_BOARD(atk_dnesp32s3);
|
DECLARE_BOARD(atk_dnesp32s3);
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
#ifndef _BOARD_CONFIG_H_
|
#ifndef _BOARD_CONFIG_H_
|
||||||
#define _BOARD_CONFIG_H_
|
#define _BOARD_CONFIG_H_
|
||||||
|
|
||||||
|
|
||||||
#include <driver/gpio.h>
|
#include <driver/gpio.h>
|
||||||
|
|
||||||
#define AUDIO_INPUT_SAMPLE_RATE 24000
|
#define AUDIO_INPUT_SAMPLE_RATE 24000
|
||||||
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
||||||
#define AUDIO_DEFAULT_OUTPUT_VOLUME 90
|
#define AUDIO_DEFAULT_OUTPUT_VOLUME 90
|
||||||
|
#define AUDIO_ADD_OUTPUT_VOLUME 90
|
||||||
|
|
||||||
#define AUDIO_I2S_GPIO_MCLK GPIO_NUM_3
|
#define AUDIO_I2S_GPIO_MCLK GPIO_NUM_3
|
||||||
#define AUDIO_I2S_GPIO_WS GPIO_NUM_9
|
#define AUDIO_I2S_GPIO_WS GPIO_NUM_9
|
||||||
|
|||||||
Reference in New Issue
Block a user