Repository navigation
Transparent audio conversion: sinc resampling, drift correction, dither - #6
Merged
Merged
Conversation
- Resampling to 44.1 kHz now uses a 256-tap sinc filter (rubato) per packet instead of linear interpolation in the capture callback. The old path measured 64 dB at 1 kHz, 22 dB at 10 kHz and lost 2.9 dB of level at 15 kHz; the new one measures 87 dB from 1 to 15 kHz with a flat response, the limit of dithered 16-bit audio. - Clock drift between sound card and network is absorbed by nudging the resampler ratio (at most ±1000 ppm) to hold the capture backlog at its target, replacing the periodic ~20 ms skips. Trimming stays only as a safety net after stalls. - 16-bit conversion uses TPDF dither and rounding instead of truncation; digital silence stays exactly silent. Tests cover tone purity and level at 1/10/15 kHz, drift tracking at +300 ppm and dither below one LSB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0153Jh6SvWis1QdJPf8i76cv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes podbeam's own audio chain transparent, for the 0.2.0 release (not tagged yet).
1. Sinc resampling instead of linear interpolation. Resampling now happens per packet, with a 256-tap sinc filter from
rubato(FFT resamplers turned off). Measured with a 48 kHz → 44.1 kHz tone:87 dB is the theoretical limit of 16-bit audio with TPDF dither.
2. Clock-drift correction instead of skips. The resampler ratio is nudged by at most ±1000 ppm (under 2 cents) to hold the capture backlog at its target. That replaces the ~20 ms skip every few minutes. Trimming stays only as a safety net after a stall, such as the PC waking from sleep. In the test with a sound card running 300 ppm fast, the backlog stays within 1 ms of target.
3. TPDF dither instead of truncation when converting to 16 bit. Quiet passages keep detail below one bit, and digital silence stays exactly silent with no dither hiss.
Testing:
-D warningson Linux and Windows.rubatois built withopt-level = 3even in debug builds, so the tests stay fast (about 2 s).cargo auditis clean.Not covered: streaming to a real HomePod from this branch. The audio path into the packet changed, but the packets themselves did not.
Generated by Claude Code