Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32s3 pdm rx录音多通道有杂音,不正常。 (IDFGH-12707) #13694

Closed
3 tasks done
crl6 opened this issue Apr 25, 2024 · 6 comments
Closed
3 tasks done

esp32s3 pdm rx录音多通道有杂音,不正常。 (IDFGH-12707) #13694

crl6 opened this issue Apr 25, 2024 · 6 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@crl6
Copy link

crl6 commented Apr 25, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

参考i2s_pdm_rx.c代码,修改gpio为:

#define EXAMPLE_PDM_RX_CLK_IO GPIO_NUM_19 // I2S PDM RX clock io number
#define EXAMPLE_PDM_RX_DIN_IO GPIO_NUM_20 // I2S PDM RX data in io number
#if CONFIG_IDF_TARGET_ESP32S3
#define EXAMPLE_PDM_RX_DIN1_IO GPIO_NUM_11 // I2S PDM RX data line1 in io number
#define EXAMPLE_PDM_RX_DIN2_IO GPIO_NUM_12 // I2S PDM RX data line2 in io number
#define EXAMPLE_PDM_RX_DIN3_IO GPIO_NUM_13 // I2S PDM RX data line3 in io number
#endif

gpio初始化:

#if CONFIG_IDF_TARGET_ESP32S3
// Only ESP32-S3 can support 4-line PDM RX
.dins = {
EXAMPLE_PDM_RX_DIN_IO,
EXAMPLE_PDM_RX_DIN_IO,
EXAMPLE_PDM_RX_DIN_IO,
EXAMPLE_PDM_RX_DIN_IO,
},
#else
.din = EXAMPLE_PDM_RX_DIN_IO,
#endif

通道配置:

#if CONFIG_IDF_TARGET_ESP32S3
// Enable all slots for example
pdm_rx_cfg.slot_cfg.slot_mode = I2S_SLOT_MODE_STEREO;
//pdm_rx_cfg.slot_cfg.slot_mask = I2S_PDM_LINE_SLOT_ALL;
pdm_rx_cfg.slot_cfg.slot_mask |= I2S_PDM_RX_LINE0_SLOT_RIGHT | I2S_PDM_RX_LINE0_SLOT_LEFT;
pdm_rx_cfg.slot_cfg.slot_mask |= I2S_PDM_RX_LINE1_SLOT_RIGHT | I2S_PDM_RX_LINE1_SLOT_LEFT;

//pdm_rx_cfg.slot_cfg.slot_mask |= I2S_PDM_RX_LINE2_SLOT_RIGHT | I2S_PDM_RX_LINE2_SLOT_LEFT;
//pdm_rx_cfg.slot_cfg.slot_mask |= I2S_PDM_RX_LINE3_SLOT_RIGHT | I2S_PDM_RX_LINE3_SLOT_LEFT;

#endif

pdm_rx_cfg.slot_cfg.slot_mask只要使用超过4通道,录音回来就不正常, 失真,杂音。

用的是同一个pmd立体声mic板子。

@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 25, 2024
@github-actions github-actions bot changed the title esp32s3 pdm rx录音多通道有杂音,不正常。 esp32s3 pdm rx录音多通道有杂音,不正常。 (IDFGH-12707) Apr 25, 2024
@crl6
Copy link
Author

crl6 commented Apr 25, 2024

PDM_RX.PCM 是6通道,16bit,16000hz。录音文件。i2s_channel_read读取回来的数据保存在psram,读取到2194304字节后,再把2194304字节写入到sd卡 PDM_RX.PCM。 可以排出是写sd卡速度问题导致的。

@L-KAYA
Copy link
Collaborator

L-KAYA commented May 20, 2024

如果要用6通道的话,那就是配3个dins信号,第四个GPIO配置为-1即可

.dins = {
    EXAMPLE_PDM_RX_DIN1_IO,
    EXAMPLE_PDM_RX_DIN2_IO,
    EXAMPLE_PDM_RX_DIN3_IO,
    -1,
},
// ...
pdm_rx_cfg.slot_cfg.slot_mask = I2S_PDM_RX_LINE0_SLOT_RIGHT | I2S_PDM_RX_LINE0_SLOT_LEFT | 
                                I2S_PDM_RX_LINE1_SLOT_RIGHT | I2S_PDM_RX_LINE1_SLOT_LEFT | 
                                I2S_PDM_RX_LINE2_SLOT_RIGHT | I2S_PDM_RX_LINE2_SLOT_LEFT;

@crl6
Copy link
Author

crl6 commented May 20, 2024

8通道也试过也是有杂音。我是慢慢减少通道数忘记去掉io配置了。i

@L-KAYA
Copy link
Collaborator

L-KAYA commented May 20, 2024

有没有试过交换通道,比如其中4个通道没问题的话,试试接到其他4个通道上,需要测试下这两种情况:

  1. 使能后4个通道,接到之前测试能用的4个mic上 (排除具体通道造成的问题)
  2. 使能前4个通道,接到另外4个mic上 (排除 mic 的问题)

如果排除了上述两种情况,那应该最后的影响因素确实是通道数量。由通道数量增加引起的杂音问题,可能的原因是:

  1. 时钟信号和4条数据信号不够同步造成时钟边缘采样不够精准;
  • 通过逻辑分析仪或者示波器观察采样时钟与数据信号对齐情况;
  1. 通道数量增加后数据吞吐量增加,写入psram较慢可能导致有数据丢失;
  • 观察音频波形是否有剪切,若有剪切现象,可以试试通过WiFi + TCP发送数据,带宽高点

@crl6
Copy link
Author

crl6 commented May 28, 2024

有没有试过交换通道,比如其中4个通道没问题的话,试试接到其他4个通道上,需要测试下这两种情况:

  1. 使能后4个通道,接到之前测试能用的4个mic上 (排除具体通道造成的问题)
  2. 使能前4个通道,接到另外4个mic上 (排除 mic 的问题)

如果排除了上述两种情况,那应该最后的影响因素确实是通道数量。由通道数量增加引起的杂音问题,可能的原因是:

  1. 时钟信号和4条数据信号不够同步造成时钟边缘采样不够精准;
  • 通过逻辑分析仪或者示波器观察采样时钟与数据信号对齐情况;
  1. 通道数量增加后数据吞吐量增加,写入psram较慢可能导致有数据丢失;
  • 观察音频波形是否有剪切,若有剪切现象,可以试试通过WiFi + TCP发送数据,带宽高点

请问WROOM-1-N16R8 的psram读写速度各是多少? wifi+tcp发送能比直接写psram快吗? 当初就是跑网络阻塞导致音频丢失,才考虑使用8m的psram

@L-KAYA
Copy link
Collaborator

L-KAYA commented May 28, 2024

请问WROOM-1-N16R8 的psram读写速度各是多少?

如果用的是R8的模组的话,menuconfig启用Octal Mode PSRAM (SPIRAM_MODE_OCT),速度可以到80MB/s,带宽应该是够的。

带宽不够导致丢数据也只是一种假设,可以通过i2s_channel_register_event_callback注册i2s_event_callbacks_t::on_recv_q_ovf 回调函数来测试,如果这个回调触发了,那说明确实有数据丢失,没有的话应该就是其他问题。

不知道前面其他的几种假设有没有排除掉?个人认为因为通道增多导致的杂音有比较大可能是线上的信号有问题,比如时钟信号驱动能力不够、时钟采样边沿和数据没对齐、线上的信号反射(阻抗匹配)、时钟信号被串扰等问题。

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

4 participants