Conversation
The Adapter and AdapterMut traits no longer carry a lifetime parameter, so all uses become Adapter<T> / AdapterMut<T>.
Indexing gains Default, new(), and chainable setters named like its fields. SincInterpolationParameters gains new(sinc_len, window) which derives f_cutoff via calculate_cutoff, with setters that keep f_cutoff consistent. Examples and the README usage block now use the fluent forms.
The synchronous Fft resampler now exposes the anti-aliasing window: new is simplified (drops sub_chunks, picking one automatically, default window) and a new new_custom exposes both sub_chunks and the window function. SincInterpolationParameters::f_cutoff becomes an Option<f32>. None (the default) derives the cutoff from sinc_len and window via calculate_cutoff, resolved after sinc_len is rounded so it matches the filter actually built. Some(value) overrides.
Derive Clone, Copy and PartialEq for ResampleError and ResamplerConstructionError so downstream code can compare, store and assert on them, and mark both #[non_exhaustive] so future variants are not breaking. Mark the chainable Indexing and SincInterpolationParameters setters #[must_use] to catch calls whose result is accidentally discarded.
Defaults to new(256, BlackmanHarris2): sinc_len 256, automatic cutoff, oversampling_factor 128, Cubic interpolation. Enables struct-update syntax and parity with Indexing.
Add Resampler::process_all, an allocating one-shot method for resampling a whole clip: it resets the resampler, trims the startup delay, and returns an InterleavedOwned with exactly the resampled frames. This gives the correct home for one-shot whole-clip resampling, which was previously done by oversizing the resampler and calling process once (leaving the startup delay untrimmed). Change process to take Option<&Indexing> instead of separate input_offset and active_channels_mask args, matching process_into_buffer. This adds partial_len support for a short final chunk (previously callers padded by hand) and makes the common call process(&input, None). output_offset is ignored since the output buffer is freshly allocated. Sharpen the process docs to point whole-clip users at process_all.
Derive PartialEq, Eq and Hash for the configuration enums (WindowFunction, SincInterpolationType, PolynomialDegree, FixedSync, FixedAsync) so they can be compared and used as map keys. Add a 'Migrating from 3.x to 4.0' section to the README with before/after examples for the breaking changes, and rework the 'Resampling a given audio clip' section to point at process_all and warn against the one-shot misuse.
There was a problem hiding this comment.
Pull request overview
This PR performs a major-version bump of rubato to 4.0.0 by upgrading to audioadapter 4.0 (removing Adapter/AdapterMut lifetimes) and introducing several API ergonomics improvements for constructing/configuring resamplers and resampling whole clips.
Changes:
- Upgrade to
audioadapter4.0 and update public APIs accordingly (trait object signatures, examples, benches). - Add fluent constructors /
DefaultforIndexingandSincInterpolationParameters, and makeSincInterpolationParameters::f_cutoffautomatic-by-default viaOption<f32>. - Improve FFT resampler construction (
Fft::newdefault behavior,Fft::new_customfor expert control) and addResampler::process_allfor one-shot clip resampling.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/windows.rs | Derive PartialEq/Eq/Hash for WindowFunction to support comparisons/keys. |
| src/synchro.rs | FFT sync resampler constructor/API updates (window selection, new vs new_custom) and audioadapter 4.0 signature updates. |
| src/lib.rs | Adds Indexing builder + Default, updates process signature, and introduces allocating process_all. |
| src/error.rs | Makes error enums #[non_exhaustive] and adds derives (Clone/Copy/PartialEq). |
| src/asynchro.rs | Updates async resampler signatures for audioadapter 4.0 and derives for FixedAsync. |
| src/asynchro_sinc.rs | Adds SincInterpolationParameters builder + Default, makes f_cutoff optional with automatic cutoff resolution. |
| src/asynchro_fast.rs | Derives PartialEq/Eq/Hash for PolynomialDegree and updates adapter mut signatures. |
| README.md | Updates documentation for new APIs and adds a 3.x → 4.0 migration guide. |
| examples/process_i16.rs | Updates example code to new parameter builders and audioadapter 4.0 API. |
| examples/process_f64.rs | Updates example code to new parameter builders and FFT constructor changes. |
| examples/process_all_f64.rs | Updates example code to new parameter builders and FFT constructor changes. |
| examples/polyfixedin_ramp64.rs | Updates example code to use Indexing::new() builder. |
| examples/fixedout_ramp64.rs | Updates example code to new parameter builders and Indexing::new() builder. |
| Cargo.toml | Bumps crate version to 4.0.0 and upgrades audioadapter dependencies to 4.0. |
| benches/resamplers.rs | Updates benches for FFT constructor changes and window selection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
update_mask now checks the provided mask length and returns WrongNumberOfMaskChannels, instead of letting copy_from_slice panic on a mismatch. Both process_into_buffer call sites propagate the error. Remove the now-dead mask-length check from validate_buffers: it only ever saw the internal channel_mask (always the right length), so it could never fire.
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.
Major release: update to
audioadapter4.0 plus a round of API ergonomics improvements.Changes
audioadapter4.0 (theAdapter/AdapterMutlifetime is gone)DefaultforIndexingandSincInterpolationParametersSincInterpolationParameters::f_cutoffis nowOption<f32>(automatic cutoff by default)Fftresampler can select the anti-aliasing window (newsimplified, newnew_custom)process_allfor one-shot whole-clip resampling;processnow takesOption<&Indexing>#[non_exhaustive]; config enums gainPartialEq/Eq/Hash; fluent setters are#[must_use]