欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > ESP32音频识别(FFT)实测调整(ESP-IDF 5.4)

ESP32音频识别(FFT)实测调整(ESP-IDF 5.4)

2025/4/27 5:17:33 来源:https://blog.csdn.net/xu_wenming/article/details/147424242  浏览:    关键词:ESP32音频识别(FFT)实测调整(ESP-IDF 5.4)

#ifndef YC_AUDIO_H

#define YC_AUDIO_H

// I2S配置(根据硬件调整)

#define I2S_CHANNEL     I2S_NUM_0

#define I2S_BCK_PIN     42

#define I2S_WS_PIN      41

#define I2S_DATA_PIN    2

/*======= 系统配置 =======*/

#define FFT_SIZE        4096           // FFT点数

#define NOISE_BINS      50            // 噪声基底计算区间

#define MIN_DURATION    5             // 最小持续帧数(50ms/帧)

#define THRESHOLD_OFFSET 20.0         // 阈值相对噪声基底的偏移量

#define FREQ_TOLERANCE  50            // 频率允许误差±50Hz

#define NUM_CHANNELS    (1)           // For mono recording only!

#define CONFIG_BIT_SAMPLE 16          //位深

#define CONFIG_SAMPLE_RATE 16000      //采样率

#define SAMPLE_SIZE     (CONFIG_BIT_SAMPLE * 1024)      //16384

#define BYTE_RATE       (CONFIG_SAMPLE_RATE * (CONFIG_BIT_SAMPLE / 8)) * NUM_CHANNELS   //32000

//存储/带宽需求小:数据量约为16000样本/秒 × 位深(如16bit)= 256kbps

extern void audio_processing_task(void *arg);

#endif

// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD

//

// Licensed under the Apache License, Version 2.0 (the "License");

// you may not use this file except in compliance with the License.

// You may obtain a copy of the License at

//

//     http://www.apache.org/licenses/LICENSE-2.0

//

// Unless required by applicable law or agreed to in writing, software

// distributed under the License is distributed on an "AS IS" BASIS,

// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

// See the License for the specific language governing permissions and

// limitations under the License.

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include "freertos/FreeRTOS.h"

#include "freertos/task.h"

#include "esp_system.h"

#include "driver/spi_master.h"

#include "soc/gpio_struct.h"

#include "driver/gpio.h"

#include "driver/uart.h"

#include "soc/uart_struct.h"

#include <math.h>

#include "esp_dsp.h"

#include "esp_log.h"

#include "esp_err.h"

#include "sdkconfig.h"

#include "driver/i2s_pdm.h"

#include "driver/spi_common.h"

#include "yc_audio.h"

#include <sys/param.h>

static const char *TAG = "audio_detect";

/*======= 硬件配置 =======*/

__attribute__((aligned(1

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词