-
Notifications
You must be signed in to change notification settings - Fork 238
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
[not for merge] Resampler low pass prototype #655
base: master
Are you sure you want to change the base?
Conversation
src/source/low_pass.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
luckily we already have a low_pass filter, see:
https://docs.rs/rodio/latest/rodio/source/trait.Source.html#method.low_pass
So the test is runnable out of box.
I have added the prototypes into src/conversions/sample_raters tests, see conversions::sample_rate::test::resampler_tweaks(). You can play with the implementation and the input parameters. The test runs 4 re-sampler versions and stores output to a wav file. The versions tested:
I hoped that primitive filter although not being good still can make meaningful difference. This does not seem to be the case. bi-quad filter is better in quality but it always uses // I wonder if we should add a chirp (frequency sweep) signal to be used in testing. |
I executed the test with mp3 sample from #584 (comment) . Note that the input mp3 has 24kHz sample rate so ideally even after resampling there should not be any frequencies above 12KHz. Moreover actual highest frequency in the input file is ~8.5KHz.Here are my results: With simple low pass: With pre-upsampled simple low pass: With bi-quad filter: I can only rely on spectrograms here, so if anyone is interested in having a better resampler in rodio is welcome to try this with your inputs. |
For a context, we plan to introduce a high quality resampler (#647). This change is an attempt to maybe also improve existing default resampler by keeping it light but improving its sound quality slightly.
Here are some resampler changes prototype that I wanted trying. See
low_pass::tests::test_low_pass
, if this will be deemed sufficiently good, down-sampling step can be optimized (just use decimation).I would like to have some objective evidence on how it performs, probably need some test harness for that. Or someone with better ears could listen to the output to compare asses it subjectively.
The low pass filter there is primitive has very slope edge, has cut-off frequency at about sample rate / 2 and may distort audio by boosting lows so the audio is up-sampled to 2 x target frequency first, and output is amplified by 0.5.
Low pass filter can be improved, but that will be slower as well. Maybe there are some people who are experienced in DSP so suggest better quick fix ideas.