Skip to content

Conversation

@78
Copy link
Owner

@78 78 commented Sep 16, 2025

This pull request introduces enhancements to the AdcPdmAudioCodec class for improved audio output control and stability, particularly by integrating a timer-based mechanism to automatically disable output after a period of inactivity. Additionally, it adds configuration flexibility for PDM upsampling, and includes some minor improvements to display and configuration files.

Audio output control and stability improvements:

  • Added an esp_timer-based mechanism to AdcPdmAudioCodec that starts a timer when audio output is enabled or data is written; the timer disables output after a 120ms timeout to prevent unwanted continuous audio output. Timer is properly created, started, stopped, and deleted as needed. (adc_pdm_audio_codec.cc, adc_pdm_audio_codec.h) [1] [2] [3] [4] [5]
  • Ensured that PDM TX clock's up_sample_fs parameter is always set according to board configuration, overriding third-party library defaults, for consistent audio performance. (adc_pdm_audio_codec.cc) [1] [2]

Configuration and flexibility:

  • Introduced AUDIO_PDM_UPSAMPLE_FS macro in config.h to allow easy adjustment of the PDM upsampling factor, improving device compatibility and audio quality. (config.h)
  • Included config.h in adc_pdm_audio_codec.cc to access new configuration macros.

Minor improvements:

  • Set explicit task priority and stack size for the emoji animation player to ensure reliable operation. (emoji_display.cc)
  • Added a stub override for SetChatMessage in EmojiWidget for interface completeness. (emoji_display.h)
  • Removed an unused configuration option from config.json for cleanup. (config.json)
  • Removed a device state change callback in esp_hi.cc that previously toggled audio output, likely superseded by the new timer-based approach. (esp_hi.cc)

@78
Copy link
Owner Author

78 commented Sep 16, 2025

@espressif2022 修复了 sample rate 不正确的问题,但是还存在哒哒哒的干扰声。这个是来自于电路上的干扰信号?

附件:test.wav

@78 78 merged commit d188415 into main Sep 16, 2025
2 checks passed
@espressif2022
Copy link
Contributor

@espressif2022 修复了 sample rate 不正确的问题,但是还存在哒哒哒的干扰声。这个是来自于电路上的干扰信号?

附件:test.wav

IDF 需要打一个补丁
企业微信截图_17452172736173

78 added a commit that referenced this pull request Sep 16, 2025
@78
Copy link
Owner Author

78 commented Sep 17, 2025

@espressif2022 修复了 sample rate 不正确的问题,但是还存在哒哒哒的干扰声。这个是来自于电路上的干扰信号?
附件:test.wav

IDF 需要打一个补丁 企业微信截图_17452172736173

目前我提交的这个方案也是可以解决的,GPT5分析了代码后写的修复方案。

        ESP_ERROR_CHECK(esp_codec_dev_open(output_dev_, &fs));
        ESP_ERROR_CHECK(esp_codec_dev_set_out_vol(output_dev_, output_volume_));

        // 强制按板卡配置重配PDM TX时钟,覆盖第三方库在set_fmt中的默认up_sample_fs
        // 若通道已启用,先禁用再重配,最后再启用
        ESP_ERROR_CHECK_WITHOUT_ABORT(i2s_channel_disable(tx_handle_));
        i2s_pdm_tx_clk_config_t clk_cfg = I2S_PDM_TX_CLK_DEFAULT_CONFIG((uint32_t)output_sample_rate_);
        clk_cfg.up_sample_fs = AUDIO_PDM_UPSAMPLE_FS;
        ESP_ERROR_CHECK(i2s_channel_reconfig_pdm_tx_clock(tx_handle_, &clk_cfg));
        ESP_ERROR_CHECK(i2s_channel_enable(tx_handle_));
        if(pa_ctrl_pin_ != GPIO_NUM_NC){
            gpio_set_level(pa_ctrl_pin_, 1);
        }

@78 78 deleted the fix_esphi branch September 27, 2025 11:54
Wvirgil123 added a commit to Wvirgil123/xiaozhi-esp32 that referenced this pull request Sep 30, 2025
* main: (43 commits)
  OTTO 左右腿反了 (78#1239)
  Bump to 2.0.3 (78#1241)
  fix emote display errors (78#1240)
  fix:小智云聊some bugfix (78#1238)
  ci: support multiple variants per board (78#1036)
  添加太极派双声道配置 (78#1235)
  fix multiple wakenet words and custom wake word (78#1226)
  添加 Waveshare ESP32-S3-Touch-LCD-3.49 (78#1227)
  New Waveshare ESP32-S3-Touch-LCD-4B third party board, 86 box form. (78#1199)
  feat: add emote style for v2 (78#1217)
  ESP32 Wifi And 4G Merge In All (78#1219)
  fix: Add function to handle local asset file paths
  Detect wake word model from index.json (78#1211)
  fix: Corrected the inverted touch screen parameter configuration of lichuang_S3_dev, which caused touch offset. (78#1209)
  fix multinet model for v2 (78#1208)
  fix: ESP-HI audio sampling problem (78#1207)
  feat: build default assets instead of downloading and v2 tables for esp-hi, echoear (78#1203)
  regenerate jpeg encoder (78#1198)
  Bump to 2.0.1
  feat: add snapshot mcp tool (78#1196)
  ...
Cmdmac pushed a commit to Cmdmac/xiaozhi-esp32 that referenced this pull request Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants