Add Slip resampler for cheap clock-drift rate matching#134
Open
HEnquist wants to merge 4 commits into
Open
Conversation
Move the capability-specific methods off the Resampler trait: set_resample_ratio and set_resample_ratio_relative go to a new Adjustable trait, set_chunk_size to a new Resizable trait. Both extend Resampler. Resampler gains as_adjustable() and as_resizable() to recover the capabilities from a trait object, defaulting to None and overridden to Some(self) by Async. This turns the runtime SyncNotAdjustable / ChunkSizeNotAdjustable errors into compile-time capabilities, so both error variants are removed. Resampler stays the universal trait for mixed Box<dyn Resampler> collections. Update the examples and tests to bring the traits into scope, and document the change in the changelog and migration guide.
Slip matches two almost-equal sample rates by occasionally inserting or dropping a frame, hidden by a short smootherstep crossfade, instead of running a full resampler. It adds no delay and no high-frequency roll-off, and its ratio is meant to be adjusted at runtime through Adjustable by a feedback loop. Several frames can be slipped per chunk (up to the crossfade spacing), so it can track up to about 10% drift.
Bind FADE to a local before asserting so the checks run on a runtime value rather than a constant expression.
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.
Adds
Slip, a very cheap resampler that matches two almost-equal sample rates byoccasionally slipping (inserting or dropping) a frame hidden by a short crossfade,
for compensating small clock differences.
Slipresampler (FixedAsync::Input/Output): no delay, no high-frequencyroll-off, very low CPU.
Adjustable, tracking up to ~10% drift. AddsResampleError::RatioOutsideRange.AdjustableandAsync.Built on top of #132 (the trait split); that should land first, and the diff here
includes #132 until it does.