Skip to content

Conversation

@roderickvd
Copy link
Member

Add rate-dependent configuration to Interpolator and use it in Sinc to apply an anti-aliasing bandwidth when downsampling. The Interpolator trait now exposes set_hz_to_hz, set_playback_hz_scale, and set_sample_hz_scale (default no-ops). The Converter methods call them automatically, without API breakage.

Fixes #174

Add rate-dependent configuration to Interpolator and use it in Sinc to
apply an anti-aliasing bandwidth when downsampling. The Interpolator
trait now exposes set_hz_to_hz, set_playback_hz_scale, and
set_sample_hz_scale (default no-ops); Converter methods call them
automatically.

Fixes #174
Copy link

Copilot AI left a comment

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 fixes aliasing issues in the Sinc interpolator during downsampling by introducing rate-dependent configuration. The changes allow the Sinc interpolator to automatically adjust its anti-aliasing bandwidth based on the sample rate conversion ratio.

Changes:

  • Extended the Interpolator trait with three rate configuration methods (set_hz_to_hz, set_playback_hz_scale, set_sample_hz_scale) with default no-op implementations
  • Modified the Sinc interpolator to store and apply a bandwidth parameter for anti-aliasing
  • Updated Converter methods to automatically configure interpolators with rate information
  • Added a test to verify anti-aliasing works correctly during downsampling

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
dasp_interpolate/src/lib.rs Added rate configuration methods to the Interpolator trait with comprehensive documentation
dasp_interpolate/src/sinc/mod.rs Added bandwidth field and implemented rate configuration methods to apply anti-aliasing
dasp_signal/src/interpolate.rs Modified from_hz_to_hz constructor and setter methods to call interpolator rate configuration
dasp_signal/tests/interpolate.rs Added test verifying anti-aliasing filters out frequencies above Nyquist during downsampling
CHANGELOG.md Documented the changes and additions to the API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@roderickvd roderickvd marked this pull request as draft January 11, 2026 10:54
@roderickvd
Copy link
Member Author

Converted to draft: spectrogram reveals that it's got some issues.

@roderickvd roderickvd force-pushed the fix/sinc-downsampling branch from 395163e to f2f0197 Compare January 11, 2026 12:46
@roderickvd roderickvd marked this pull request as ready for review January 11, 2026 12:51
@roderickvd
Copy link
Member Author

There, that should be better.

@roderickvd roderickvd force-pushed the fix/sinc-downsampling branch from f2f0197 to 9668870 Compare January 12, 2026 21:13
@roderickvd roderickvd force-pushed the fix/sinc-downsampling branch from a38546d to b94688e Compare January 12, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Downsampling using Sinc causes aliasing

2 participants