Skip to content

fix: 核心功能修复:Steam Streaming Microphone 统一双声道 32-bit 48 kHz,修复安装后音频爆炸 - #399

Merged
OrientCOMPASS merged 4 commits into
MicYou-Dev:masterfrom
OrientCOMPASS:fix/steam-audio-endpoint-format
Nov 21, 2026
Merged

OrientCOMPASS merged 4 commits into
MicYou-Dev:masterfrom
OrientCOMPASS:fix/steam-audio-endpoint-format

Conversation

@OrientCOMPASS

@OrientCOMPASS OrientCOMPASS commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

问题

PR #394 将 Windows 虚拟麦克风切换为 Valve 的 Steam Streaming Microphone 后,默认安装下会出现严重的音频爆炸。实测与逆向确认根因:

  • 该驱动是 PortCls WaveCyclic miniport,render/capture 共用一块 原始字节环形缓冲;CopyTo/CopyFrom 只按字节搬运,不做声道、位深、采样率转换。
  • 驱动本身只接受 8 声道 PCM、8–32 bit、8k–192k;Windows 音频引擎负责 2ch 端点与 8ch 驱动流之间的转换。
  • 24-bit packed 端点存在歧义:端点 DeviceFormat 是 3 字节 packed,而引擎 mix format 是 32-bit 容器/24 valid;引擎可能在 render 和 capture 两条路径上分别选择 24-bit(3 字节)与 32-bit(4 字节),原始字节环回被按错误帧宽解释,产生确定性的 9 kHz / 23 kHz 爆音。
  • 16-bit 与 32-bit 端点的容器宽度唯一,两侧字节几何一致,回路干净。

修复

  • configure.ps1 将 Steam Streaming Microphone 的 render/capture 两个端点统一配置为 2ch / 48 kHz / 32-bit PCM,对齐 MicYou 的双声道 48 kHz F32LE DSP 链,24-bit 源素材无损;同时保持 capture 增益 0 dB、关闭独占模式,并做幂等校验。
  • engine.rs 更新 2 声道/48 kHz 检测与告警文案,并删除已不再使用的 I24 输出路径(32-bit 端点的 mix 是 F32,旧的 24-bit packed 路径既无必要也不安全)。
  • 删除 .github/workflows/web-client.yml。

验证

  • 实机干净安装后验证可用。
  • 从 capture 端 1ch/44.1k/32 的错配状态执行 configure.ps1,自动修正为双端 2ch/48k/32-bit;重复执行幂等,exit 0。
  • 向 render 播放 1 kHz 正弦、从 capture 录回,连续多次均为 rms≈0.0707、主频 1 kHz,无爆音。
  • 24-bit 端点可稳定复现 9 kHz / 23 kHz 两种爆音模式,与静态分析结论一致。
  • CI run 44879091448 全部通过(Windows/macOS/Linux/Android)。

影响

  • tauri-app/src-tauri/resources/steam-audio/configure.ps1
  • tauri-app/crates/micyou-audio/src/engine.rs
  • tauri-app/crates/micyou-core/src/platform/steam_audio.rs
  • tauri-app/src-tauri/installer.iss
  • AGENTS.md、README*.md、resources/steam-audio/README.md
  • .github/workflows/web-client.yml(删除)

行为变化:不再使用 24-bit packed 端点(无法保证稳定),改为 32-bit 容器;Sound 面板会显示 32-bit,但 24-bit 源音频无损,且与 F32LE DSP 链一致。

Valve's driver ships with a multichannel render endpoint, a +30 dB capture boost and render/capture formats that can disagree. A default install ended up with a 48 kHz 16-bit render side and a 44.1 kHz 32-bit capture side, which makes the loopback resampler produce extremely loud artifacts.

configure.ps1 now sets both endpoints to stereo 24-bit 48 kHz, disables the exclusive-mode policy through the endpoint property store, and verifies the result after cycling AudioEndpointBuilder. The format change is skipped for an endpoint that already has the target format (SetDeviceFormat returns E_ACCESSDENIED for a no-op).

The output engine gains a 24-bit path because WASAPI reports the new endpoint format as I24, and the in-app repair check now requires stereo instead of accepting the old mono endpoint.
The Steam Streaming Microphone WaveCyclic driver copies raw bytes between its render and capture streams: it performs no channel, bit-depth or sample-rate conversion, so both streams must hand the driver identical byte geometry. A 24-bit packed endpoint is ambiguous because the Windows mix format is a 32-bit container with 24 valid bits; the engine can pick 24-bit (3-byte) for one stream and 32-bit (4-byte) for the other, which the raw ring then misreads as the periodic explosion users reported after a default install. 16-bit and 32-bit endpoints are unambiguous and loop back cleanly.

Configure both endpoints as stereo 48 kHz 32-bit PCM instead, matching MicYou's stereo 48 kHz F32LE DSP chain, keep 24-bit source material lossless, and keep exclusive mode disabled. Verified on the Steam driver: 24-bit endpoints reproduce the deterministic 9 kHz/23 kHz explosion, while the 32-bit configuration loops a 1 kHz tone back at the correct level and frequency across repeated runs, and configure.ps1 is idempotent.
@micyou-automation micyou-automation Bot added waitmerge 等待合并 size/l 100-499 行 reviewing 正在复核 and removed waitmerge 等待合并 labels Nov 21, 2026
@micyou-automation micyou-automation Bot removed reviewing 正在复核 size/l 100-499 行 labels Nov 21, 2026
@OrientCOMPASS OrientCOMPASS reopened this Nov 21, 2026
@micyou-automation micyou-automation Bot added reviewing 正在复核 size/l 100-499 行 labels Nov 21, 2026
@OrientCOMPASS OrientCOMPASS changed the title 核心功能修复:Steam Streaming Microphone 统一双声道 32-bit 48 kHz,修复安装后音频爆炸 fix: 核心功能修复:Steam Streaming Microphone 统一双声道 32-bit 48 kHz,修复安装后音频爆炸 Nov 21, 2026
@micyou-automation micyou-automation Bot added waitmerge 等待合并 and removed reviewing 正在复核 labels Nov 21, 2026
@OrientCOMPASS
OrientCOMPASS merged commit e204f35 into MicYou-Dev:master Nov 21, 2026
6 of 10 checks passed
@micyou-automation micyou-automation Bot added done 完成 reviewing 正在复核 and removed waitmerge 等待合并 done 完成 labels Nov 21, 2026
@OrientCOMPASS
OrientCOMPASS deleted the fix/steam-audio-endpoint-format branch November 25, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewing 正在复核 size/l 100-499 行

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant