Skip to content

Update to audioadapter 4.0 and bump to 4.0.0#133

Open
HEnquist wants to merge 9 commits into
masterfrom
next4.0
Open

Update to audioadapter 4.0 and bump to 4.0.0#133
HEnquist wants to merge 9 commits into
masterfrom
next4.0

Conversation

@HEnquist

Copy link
Copy Markdown
Owner

Major release: update to audioadapter 4.0 plus a round of API ergonomics improvements.

Changes

  • Update to audioadapter 4.0 (the Adapter/AdapterMut lifetime is gone)
  • Fluent constructors and Default for Indexing and SincInterpolationParameters
  • SincInterpolationParameters::f_cutoff is now Option<f32> (automatic cutoff by default)
  • The Fft resampler can select the anti-aliasing window (new simplified, new new_custom)
  • process_all for one-shot whole-clip resampling; process now takes Option<&Indexing>
  • Error enums gain derives + #[non_exhaustive]; config enums gain PartialEq/Eq/Hash; fluent setters are #[must_use]
  • Added a 3.x to 4.0 migration guide to the README

HEnquist added 7 commits June 21, 2026 21:39
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 audioadapter 4.0 and update public APIs accordingly (trait object signatures, examples, benches).
  • Add fluent constructors / Default for Indexing and SincInterpolationParameters, and make SincInterpolationParameters::f_cutoff automatic-by-default via Option<f32>.
  • Improve FFT resampler construction (Fft::new default behavior, Fft::new_custom for expert control) and add Resampler::process_all for 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.

Comment thread src/asynchro.rs
Comment thread src/synchro.rs
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.
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.

2 participants