[not for merge] Resampler low pass prototype#655
[not for merge] Resampler low pass prototype#655PetrGlad wants to merge 11 commits intoRustAudio:masterfrom
Conversation
There was a problem hiding this comment.
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. |
|
Hey Petr, sorry for letting this one sit for so long. We are about to add rubato as a high quality resampler however there are a few others out there build for performance. I agree there is absolutely a use case for a lower quality but higher performance resampler. Maybe it makes senses to add some of those other resamplers as an option. Roderick has some context on that. For now I'm closing this prototype to clean up the PR list. |




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.