forked from xiaozhi/xiaozhi-esp32
增强T-CameraPlus-S3麦克风接收音量 (#958)
* Adapt for LilyGO-T-Circle-S3 device * Adapt for LilyGO-T-Circle-S3 device * Remove comments and modify the size of the lilygo-t-circle-s3 image * Modify the code style and format to Google C++ * Modify the code style and format to Google C++ * Fixed bugs in the LILYGO T-Circle-S3 board and added support for two new boards: LILYGO T-Display-S3-Pro-MVSRLora and LILYGO T-Display-S3-Pro-MVSRLora_NO_BATTERY. * Added support for two new boards: LILYGO T-Display-S3-Pro-MVSRLora and LILYGO T-Display-S3-Pro-MVSRLora_NO_BATTERY. * Merge branch 'main' of https://github.com/Llgok/xiaozhi-esp32 * Added support for two new boards: LILYGO T-Display-S3-Pro-MVSRLora and LILYGO T-Display-S3-Pro-MVSRLora_NO_BATTERY. * Added support for two new boards: LILYGO T-Display-S3-Pro-MVSRLora and LILYGO T-Display-S3-Pro-MVSRLora_NO_BATTERY. * Added support for two new boards: LILYGO T-Display-S3-Pro-MVSRLora and LILYGO T-Display-S3-Pro-MVSRLora_NO_BATTERY. * Added support for two new boards: LILYGO T-Display-S3-Pro-MVSRLora and LILYGO T-Display-S3-Pro-MVSRLora_NO_BATTERY. * Fix the color display issue for T-Display-S3-Pro-MVSRLora and LILYGO T-Display-S3-Pro-MVSRLora_NO_BATTERY. * Update T-CameraPlus-S3_V1.2 Version Xiaozhi Example * Resolve the issue where the camera on the T-CameraPlus-S3_V1.2 board cannot be used normally. * Enhance microphone reception volume * fix the issue where voice wake-up is not working * fix the issue where voice wake-up is not working
This commit is contained in:
@@ -4,15 +4,16 @@
|
||||
#include <driver/gpio.h>
|
||||
#include "pin_config.h"
|
||||
|
||||
#define AUDIO_INPUT_REFERENCE true
|
||||
#define AUDIO_INPUT_SAMPLE_RATE 24000
|
||||
#define AUDIO_INPUT_SAMPLE_RATE 16000
|
||||
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
||||
|
||||
#ifdef CONFIG_BOARD_TYPE_LILYGO_T_CAMERAPLUS_S3_V1_0_V1_1
|
||||
#define AUDIO_INPUT_REFERENCE true
|
||||
#define AUDIO_MIC_I2S_GPIO_BCLK static_cast<gpio_num_t>(MSM261_BCLK)
|
||||
#define AUDIO_MIC_I2S_GPIO_WS static_cast<gpio_num_t>(MSM261_WS)
|
||||
#define AUDIO_MIC_I2S_GPIO_DATA static_cast<gpio_num_t>(MSM261_DATA)
|
||||
#elif defined CONFIG_BOARD_TYPE_LILYGO_T_CAMERAPLUS_S3_V1_2
|
||||
#define AUDIO_INPUT_REFERENCE false
|
||||
#define AUDIO_MIC_I2S_GPIO_BCLK GPIO_NUM_NC
|
||||
#define AUDIO_MIC_I2S_GPIO_WS static_cast<gpio_num_t>(MP34DT05TR_LRCLK)
|
||||
#define AUDIO_MIC_I2S_GPIO_DATA static_cast<gpio_num_t>(MP34DT05TR_DATA)
|
||||
|
||||
@@ -140,10 +140,17 @@ void Tcamerapluss3AudioCodec::EnableOutput(bool enable) {
|
||||
AudioCodec::EnableOutput(enable);
|
||||
}
|
||||
|
||||
int Tcamerapluss3AudioCodec::Read(int16_t *dest, int samples){
|
||||
if (input_enabled_){
|
||||
int Tcamerapluss3AudioCodec::Read(int16_t *dest, int samples) {
|
||||
if (input_enabled_) {
|
||||
size_t bytes_read;
|
||||
i2s_channel_read(rx_handle_, dest, samples * sizeof(int16_t), &bytes_read, portMAX_DELAY);
|
||||
|
||||
// 麦克风接收音量放大20倍(限制在 int16_t 范围内防止溢出)
|
||||
int16_t *ptr = dest;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
int32_t amplified = *ptr * 20;
|
||||
*ptr++ = (amplified > 32767) ? 32767 : (amplified < -32768) ? -32768 : amplified;
|
||||
}
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user