Fix out two channel.

This commit is contained in:
Colin 2026-01-03 23:17:49 +08:00
parent f0d0856b7e
commit fc3aa09789
2 changed files with 9 additions and 5 deletions

View File

@ -59,7 +59,7 @@ esp_err_t record_start2() {
esp_err_t ret = ESP_OK;
const wav_header_t wav_header2 =
WAV_HEADER_PCM_DEFAULT(16000 * 2 * 16 / 8 * 20, 16, 16000, 2);
WAV_HEADER_PCM_DEFAULT(16000 * 1 * 16 / 8 * 20, 16, 16000, 1);
f2 = fopen("/sdcard/bbbbb.wav", "w");
ESP_LOGI(TAG, "fopen error: %s", strerror(errno));
@ -96,7 +96,7 @@ bool record_end1() { return wav_written1 == 0xFFFFFFFF; }
bool record_end2() { return wav_written2 == 0xFFFFFFFF; }
esp_err_t record_add2(int16_t* data2, uint32_t size) {
uint32_t byte_rate = 16000 * 2 * 16 / 8;
uint32_t byte_rate = 16000 * 1 * 16 / 8;
uint32_t wav_size = byte_rate * 20;
if (wav_written2 < wav_size) {
@ -125,7 +125,10 @@ afe_fetch_result_t* afe(esp_afe_sr_data_t* afe_data, int16_t* i2s_buff) {
// printf("AFE get_fetch_chunksize: %d\n",
// afe_handle->get_fetch_chunksize(afe_data));
// afe_handle->print_pipeline(afe_data);
// printf("AFE get_channel_num: %d\n", afe_handle->get_channel_num(afe_data));
// printf("AFE get_feed_channel_num: %d\n",
// afe_handle->get_feed_channel_num(afe_data));
// printf("AFE get_fetch_channel_num: %d\n",
// afe_handle->get_fetch_channel_num(afe_data));
// printf("AFE get_samp_rate: %d\n", afe_handle->get_samp_rate(afe_data));
afe_fetch_result_t* res = NULL;

View File

@ -253,12 +253,13 @@ static void i2s_rx_task(void* arg) {
afe_fetch_result_t* res = afe(afe_sr_data, data_buffer);
if (res != NULL) {
record_add2(res->data, res->data_size);
record_add2(res->data, res->data_size / 2);
if (res->vad_state > 0) {
printf("AFE data_size: %d\n", res->data_size);
printf("AFE data_size: %d\n", res->data_size / 2);
// printf("AFE data_volume: %f\n", res->data_volume);
// printf("AFE vad_state: %d\n", res->vad_state);
// printf("AFE ret_value: %d\n", res->ret_value);
// printf("AFE raw_data_channels: %d\n", res->raw_data_channels);
}
}