From 5b700f4c780608096835c7d44c26d5b10cd994a9 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 24 Jul 2023 18:03:20 +0800 Subject: [PATCH] update --- demo/ac_sound_capture1/ac_sound_capture1.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/demo/ac_sound_capture1/ac_sound_capture1.cpp b/demo/ac_sound_capture1/ac_sound_capture1.cpp index 48fd5bd..d3171d4 100644 --- a/demo/ac_sound_capture1/ac_sound_capture1.cpp +++ b/demo/ac_sound_capture1/ac_sound_capture1.cpp @@ -91,6 +91,7 @@ class WAVHeader { header.subchunk2_size = wavbinsize; } + void dump() { printf("chunk_id: %s\n", string(header.chunk_id, 4).c_str()); printf("chunk_size: %d\n", header.chunk_size); @@ -153,7 +154,11 @@ void wavWriteVoice(string filename, uint32_t sample_rate, uint16_t bits_per_samp void sound_capture_callback(int32_t* voicedata, uint32_t len) { printf("sound_capture_callback:%d\n", len); for (size_t i = 0; i < len; i++) { - voicedata[i] = voicedata[i] << 8; //底层采集的数据是24位,左移8位转换成32位 + voicedata[i] = voicedata[i] << 8; // 底层采集的数据是24位,左移8位转换成32位 + } + + for (size_t i = 0; i < len; i++) { + voicedata[i] = voicedata[i] - 421600000; // 减去声望AC输出的直流偏量 } wavWriteVoice("record.wav", 64000, 32, 1, (char*)voicedata, len * sizeof(int32_t));