Skip to content

mic: match capture to the independent I2S output clock - #2456

Closed
sshane wants to merge 1 commit into
commaai:masterfrom
sshane:fix-mic-clock-matching
Closed

sshane wants to merge 1 commit into
commaai:masterfrom
sshane:fix-mic-clock-matching

Conversation

@sshane

@sshane sshane commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

The microphone decimator produces approximately 47,952 samples/s while the independent I2S clock consumes approximately 48,000. Copying whole input blocks into whichever output buffer is inactive eventually retransmits an old 512-sample block. Baseline desk captures reproduced this about every 10.53 seconds; changing the nominal divider alone still failed a longer capture.

Fill output buffers on I2S DMA completion and continuously read the input ring at a rate corrected from buffer occupancy. Retain the previously tested cubic interpolation, saturation, and one-block fade when establishing a read position. Original microphone clock, decimation, gain, buffer sizes, and I2S format remain unchanged.

This extracts only the clock-matching implementation from #2454: 79 added / 14 removed lines in one file, with no investigation tools or recordings. Startup output-memory initialization is separate in #2455; openpilot integration is commaai/openpilot#38984. This is a resampler and buffer-control change, not a one-line clock-divider fix.

Validation:

  • H7 firmware build and the repository's intended MISRA checker pass on this extracted branch.
  • Actual-C UBSan simulation passes 320 seconds at each of five input clock offsets (-2000, -1000, 0, +20, +2000 ppm), with producer-position jitter and a continuous 1 kHz test tone.
  • The same clock-matching implementation was tested on-device during comma four: microphone pop fixes and audio quality investigation #2454, including a 300-second run without repeated blocks or resynchronization. Those captures also included the separate startup fix; no fresh device capture was made for this extraction.

Remaining review: concurrent DMA/interrupt behavior under normal on-road workload, added capture latency, and resampling response. This addresses the reproduced repeated-block defect; it does not claim to eliminate every acoustic transient or the separate unexplained driving discontinuity.

@sshane

sshane commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Replaced by #2457

@sshane sshane closed this Sep 21, 2026
@sshane
sshane deleted the fix-mic-clock-matching branch September 21, 2026 03:08
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.

1 participant