What’s the best algorithm to change sample rate of PCM audio?
The input is often int16_t
at 44.1 kHz but can also be 32kHz or other frequency. The output I need is 32-bit float
at 48 kHz. I’m proficient in SIMD intrinsics and guaranteed to have either NEON or AVX, so an algorithm based on float math is OK.
Do I need to implement FFT inverse, or is there something less computationally expensive?
For instance, will cubic splines work for this use case, or they gonna introduce frequency artifacts?
CodePudding user response:
Yes, FFT is the requirement for good quality.
This web site has nice graphs of more than 100 pieces of software who are doing audio resampling. From a prior experience, I knew the professional software made by Steinberg is often doing the right things. The graphs on that web site agree, for Cubase 10 and Nuendo 11 these graphs are very good indeed.
Fortunately for me, pretty much the same quality is produced by ffmpeg 4.2.2 with soxr resampler. That particular resampling library comes with a good enough license, and the DLL is even available as a package for my target OS.
I have integrated that library. While playing back 44.1 kHz wave file resampling in runtime into 48 kHz, my test program only consumes about 1% of CPU time (the CPU is quad code Allwinner A64 @ 1 GHz) so the performance is good despite the FFT.
Back to my original question, the algorithm implemented in that library is from the 2005 paper by Laurent de Soras “The Quest For The Perfect Resampler”.
As written in the readme, it combines Julius O. Smith's `Bandlimited Interpolation' technique with FFT-based over-sampling. The math is rather complicated there. I was lucky to find that library as I would have wasted too much time trying to do something similar myself.