Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New resampler: aliasing when downsampling #2715

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 2 comments
Closed

New resampler: aliasing when downsampling #2715

SDLBugzilla opened this issue Feb 11, 2021 · 2 comments
Assignees

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.7
Reported for operating system, platform: Other, x86

Comments on the original bug report:

On 2017-11-11 18:44:49 +0000, Eric Wasylishen wrote:

Created attachment 3084
sine sweep test case

The issue is SDL_ResampleAudio currently lowpass filters at 0.5*inrate, even in the case when outrate < inrate. In other words, the part of the "band-limited resampling" paper that says - "if rho < 1... the step-size through the filter table is reduced.." is not implemented.

Here is a test case with a 0-48kHz sine sweep sampled at 96kHz.

testresample sweep96k.wav sweep44100.wav 44100 1
sox sweep44100.wav -n spectrogram -o sweep44100.png
open sweep44100.png

(careful with the volume if you play these!)

It should be resampled as a single upward sweep that stops at the 22kHz nyquist limit with silence after that, but currently you get a siren effect due to the aliasing.
I have a patch in the works for this.

@0x1F9F1
Copy link
Collaborator

0x1F9F1 commented Aug 22, 2023

I could have a go at implementing this if it would be useful, though I'm not sure any improvements would outweigh the increased complexity.
It only applies to downsampling (dst_rate < src_rate), which (ignoring pitch shifting) I don't think SDL does much beyond something like 48000 -> 44100 (where I imagine the difference would be minimal).

@icculus
Copy link
Collaborator

icculus commented Oct 4, 2023

Using the test case in the original bug report...

SDL2's resampler:

sweep44100

SDL3's resampler:

sweep44100

I think I'm okay with this outcome...?

@slouken slouken closed this as completed Nov 5, 2023
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

No branches or pull requests

4 participants