当前位置: 首页 > news >正文

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

相关文章:

  • 蓝桥杯常考的找规律题
  • 小白工具视频转MPG, 功能丰富齐全,无需下载软件,在线使用,超实用
  • hi3516cv610构建音频sample工程代码步骤
  • 【Nova UI】六、SASS 赋能组件库:通用方法与混入的变革力量
  • 【FreeRTOS】简介
  • 使用resend通过调用api接口的方式发送邮件,可以自定义域
  • 模型 螃蟹效应
  • 前台调用接口的方式及速率对比
  • 品牌如何通过朝日新闻出海日本?——某企业日本媒体发稿实战
  • XSS的应用
  • 工厂模式:工厂方法模式 和 抽象工厂模式
  • 闲聊人工智能对媒体的影响
  • 20.4 显示数据库数据
  • rpm命令详解
  • 【通过Docker快速部署Tomcat9.0】
  • 考研单词笔记 2025.04.22
  • rgw的d3n功能配置
  • 使用Java对接StockTV全球金融数据API。马来西亚金融数据API
  • B + 树与 B 树的深度剖析
  • 【扫描件批量改名】批量识别扫描件PDF指定区域内容,用识别的内容修改PDF文件名,基于C++和腾讯OCR的实现方案,超详细
  • “五一”从昆明机场出境1.4万人次,较去年增长7.7%
  • 中央气象台:未来三天北方地区有大风沙尘,江南等地有强降水
  • 5月人文社科中文原创好书榜|巫蛊:中国文化的历史暗流
  • 澎湃读报丨解放日报8个版聚焦:牢记嘱托,砥砺奋进
  • 光明日报社论:用你我的匠心,托举起繁盛的中国
  • 王毅:时代不容倒退,公道自在人心