尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

【ESP32 在线语音】音频接收的缓存机制

【ESP32 在线语音】音频接收的缓存机制
📅 发布时间:2026/6/18 17:29:57

首先是初始化 I2S 设备中,可能用到了缓存

//初始化 I2S 设备 INMP441Serial.println("Setup I2S ...");i2s_install();i2s_setpin();esp_err_t err = i2s_start(I2S_PORT_0);

 其中的  i2s_install() 配置了 i2s 的相关设置,函数具体内容如下:

/*** @brief 配置 i2s 参数* */
void i2s_install()
{const i2s_config_t i2s_config = {.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),.sample_rate = SAMPLE_RATE,.bits_per_sample = i2s_bits_per_sample_t(16),.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),.intr_alloc_flags = 0, // default interrupt priority.dma_buf_count = 8,.dma_buf_len = 1024,.use_apll = false};esp_err_t err = i2s_driver_install(I2S_PORT_0, &i2s_config, 0, NULL);if (err != ESP_OK){Serial.printf("I2S driver install failed (I2S_PORT_0): %d\n", err);while (true);}else{Serial.printf("I2S driver install OK\r\n");}
}

其中,与缓存有关的包括下面的结构体成员和 i2s_driver_install() 函数:

     .dma_buf_count = 8,.dma_buf_len = 1024,int                     dma_buf_count;              /**< The total number of DMA buffers to receive/transmit data.* A descriptor includes some information such as buffer address,* the address of the next descriptor, and the buffer length.* Since one descriptor points to one buffer, therefore, 'dma_desc_num' can be interpreted as the total number of DMA buffers used to store data from DMA interrupt.* Notice that these buffers are internal to'i2s_read' and descriptors are created automatically inside of the I2S driver.* Users only need to set the buffer number while the length is derived from the parameter described below.*/int                     dma_buf_len;                /**< Number of frames in a DMA buffer.*  A frame means the data of all channels in a WS cycle.*  The real_dma_buf_size = dma_buf_len * chan_num * bits_per_chan / 8.*  For example, if two channels in stereo mode (i.e., 'channel_format' is set to 'I2S_CHANNEL_FMT_RIGHT_LEFT') are active,*  and each channel transfers 32 bits (i.e., 'bits_per_sample' is set to 'I2S_BITS_PER_CHAN_32BIT'),*  then the total number of bytes of a frame is 'channel_format' * 'bits_per_sample' = 2 * 32 / 8 = 8 bytes.*  We assume that the current 'dma_buf_len' is 100, then the real length of the DMA buffer is 8 * 100 = 800 bytes.*  Note that the length of an internal real DMA buffer shouldn't be greater than 4092.*/

 从注释(Notice that these buffers are internal to'i2s_read)可以得到 , DMA功能的使用,指定即可,而不需要自己实现——内部会自动完成相关的配置。

 

i2s_driver_install() 函数定义如下

/*** @brief Install and start I2S driver.** @param i2s_num         I2S port number** @param i2s_config      I2S configurations - see i2s_config_t struct** @param queue_size      I2S event queue size/depth.*i2s 队列尺寸           I2S事件队列尺寸* @param i2s_queue       I2S event queue handle, if set NULL, driver will not use an event queue.* /*i2s 队列            I2S事件队列句柄* This function must be called before any I2S driver read/write operations.** @return*     - ESP_OK              Success*     - ESP_ERR_INVALID_ARG Parameter error*     - ESP_ERR_NO_MEM      Out of memory*     - ESP_ERR_INVALID_STATE  Current I2S port is in use*/
esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, int queue_size, void *i2s_queue);

 实际代码中没有使用,暂时也不知道所谓的 I2S 时间是什么?(莫非可能自动检测VAD端点检测?)

 

相关新闻

  • 一文吃透银行账务打通体系闭环 - 智慧园区
  • uups 逻辑合约也增加了升级函数,那总体不是也费gas吗?
  • 【URP】Unity[纹理压缩]算法多平台对比

最新新闻

  • 应用层核心(一):从FTP到DNS的进阶指南
  • 毕节黄金回收指南:六家靠谱店铺推荐,让闲置安心变现 - 清奢黄金上门回收
  • AI炒股不是预测股价,而是校准认知:信息保真度实战指南
  • 2026鹰潭余江区黄金回收靠谱门店全盘点!30年老品牌全城覆盖,免费上门无隐形扣费 - 衡金阁
  • Geatpy进化算法工具箱:Python高性能优化计算的终极解决方案
  • Sirius内存管理技术:cuCascade分层内存与磁盘溢出机制

日新闻

  • 2026年不锈钢卷板厂家推荐排行榜:冷轧热轧/304/201不锈钢卷板,高颜值耐腐蚀源头厂家实力精选 - 企业推荐官【官方】
  • FLUX.1-dev FP8模型实战指南:24GB以下显卡高效部署方案
  • 2026佛山长途搬家价目表:跨省跨市搬家费用完整计算指南 - 从来都是英雄出少年

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号