Skip to content

Commit

Permalink
Merge branch 'feature/s3_1mic_sr_v2_4' into 'release/v2.4'
Browse files Browse the repository at this point in the history
1 mic support for korvo2 in example `wwe` (backport release/v2.4)

See merge request adf/esp-adf-internal!1083
  • Loading branch information
jason-mao committed Sep 3, 2022
2 parents 8cabba5 + baac742 commit 677ecbb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions components/audio_hal/driver/es7210/es7210.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ esp_err_t es7210_mic_select(es7210_input_mics_t mic)
if (mic_num >= ENABLE_TDM_MAX_NUM) {
ret |= es7210_write_reg(ES7210_SDP_INTERFACE2_REG12, 0x02);
ESP_LOGW(TAG, "Enable TDM mode. ES7210_SDP_INTERFACE2_REG12: %X", es7210_read_reg(ES7210_SDP_INTERFACE2_REG12));
} else {
ret |= es7210_write_reg(ES7210_SDP_INTERFACE2_REG12, 0x00);
ESP_LOGW(TAG, "Disable TDM mode. ES7210_SDP_INTERFACE2_REG12: %X", es7210_read_reg(ES7210_SDP_INTERFACE2_REG12));
}
return ret;
}
Expand Down
20 changes: 19 additions & 1 deletion examples/speech_recognition/wwe/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "recorder_encoder.h"
#include "recorder_sr.h"
#include "tone_stream.h"
#include "es7210.h"

#include "model_path.h"

Expand Down Expand Up @@ -126,8 +127,12 @@ static esp_audio_handle_t setup_player()
// Create writers and add to esp_audio
i2s_stream_cfg_t i2s_writer = I2S_STREAM_CFG_DEFAULT();
i2s_writer.i2s_config.sample_rate = 48000;
#if (CONFIG_ESP32_S3_KORVO2_V3_BOARD == 1) && (CONFIG_AFE_MIC_NUM == 1)
i2s_writer.i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
#else
i2s_writer.i2s_config.bits_per_sample = CODEC_ADC_BITS_PER_SAMPLE;
i2s_writer.need_expand = (CODEC_ADC_BITS_PER_SAMPLE != I2S_BITS_PER_SAMPLE_16BIT);
#endif
i2s_writer.type = AUDIO_STREAM_WRITER;

esp_audio_output_stream_add(player, i2s_stream_init(&i2s_writer));
Expand Down Expand Up @@ -286,7 +291,11 @@ static void start_recorder()
i2s_cfg.i2s_port = CODEC_ADC_I2S_PORT;
i2s_cfg.i2s_config.use_apll = 0;
i2s_cfg.i2s_config.sample_rate = CODEC_ADC_SAMPLE_RATE;
#if (CONFIG_ESP32_S3_KORVO2_V3_BOARD == 1) && (CONFIG_AFE_MIC_NUM == 1)
i2s_cfg.i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
#else
i2s_cfg.i2s_config.bits_per_sample = CODEC_ADC_BITS_PER_SAMPLE;
#endif
i2s_cfg.type = AUDIO_STREAM_READER;
i2s_stream_reader = i2s_stream_init(&i2s_cfg);

Expand All @@ -295,7 +304,7 @@ static void start_recorder()
rsp_filter_cfg_t rsp_cfg = DEFAULT_RESAMPLE_FILTER_CONFIG();
rsp_cfg.src_rate = CODEC_ADC_SAMPLE_RATE;
rsp_cfg.dest_rate = 16000;
#ifdef CONFIG_ESP32_S3_KORVO2_V3_BOARD
#if (CONFIG_ESP32_S3_KORVO2_V3_BOARD == 1) && (CONFIG_AFE_MIC_NUM == 2)
rsp_cfg.mode = RESAMPLE_UNCROSS_MODE;
rsp_cfg.src_ch = 4;
rsp_cfg.dest_ch = 4;
Expand Down Expand Up @@ -329,6 +338,15 @@ static void start_recorder()
recorder_sr_cfg.multinet_init = MULTINET_ENABLE;
recorder_sr_cfg.afe_cfg.aec_init = RECORD_HARDWARE_AEC;
recorder_sr_cfg.afe_cfg.agc_mode = AFE_MN_PEAK_NO_AGC;
#if (CONFIG_ESP32_S3_KORVO2_V3_BOARD == 1) && (CONFIG_AFE_MIC_NUM == 1)
recorder_sr_cfg.afe_cfg.pcm_config.mic_num = 1;
recorder_sr_cfg.afe_cfg.pcm_config.ref_num = 1;
recorder_sr_cfg.afe_cfg.pcm_config.total_ch_num = 2;
recorder_sr_cfg.input_order[0] = DAT_CH_0;
recorder_sr_cfg.input_order[1] = DAT_CH_1;

es7210_mic_select(ES7210_INPUT_MIC1 | ES7210_INPUT_MIC3);
#endif

#if RECORDER_ENC_ENABLE
recorder_encoder_cfg_t recorder_encoder_cfg = { 0 };
Expand Down

0 comments on commit 677ecbb

Please sign in to comment.