jniemann66 / ReSampler

High quality command-line audio sample rate converter
GNU Lesser General Public License v2.1
160 stars 25 forks source link

Dear @jniemann66, it seems I have found a sample that puts ReSampler to shame. #38

Open jniemann66 opened 8 months ago

jniemann66 commented 8 months ago
          Dear @jniemann66, it seems I have found a sample that puts ReSampler to shame.

54321.flac.zip

$ mediainfo 54321.flac
Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
Duration                                 : 5 s 0 ms
Bit rate mode                            : Variable
Bit rate                                 : 308 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 54.3 kHz
Bit depth                                : 16 bits
Compression mode                         : Lossless
Stream size                              : 188 KiB (96%)
Writing library                          : libFLAC 1.4.3 (2023-06-23)
MD5 of the unencoded content             : 1151627D253AD4436776CEF9C21B84C8

$ resampler -i 54321.flac -o out.wav -r 44100 --doubleprecision --dither --autoblank
2.1.0 64-bit version
Input file: 54321.flac
Output file: out.wav
Output Bit Format not specified
Changing output file format to wav
Using double precision for calculations.
input bit format: 16
source file channels: 2
input sample rate: 54321
output sample rate: 44100
Scanning input file for peaks ...Done
Peak input sample: 0.251221 (-11.998891 dBFS) at 0:0:0.903315
LPF transition frequency: 20045.45 Hz (90.91 %)
Conversion ratio: 0.811841 (14700:18107)
Generating 1.00 bits of standard dither for 16-bit output format, with auto-blanking
Writing Metadata
Converting (multi-stage) ...
Writing to output file ...
Done
Peak output sample: 0.112339 (-18.989417 dBFS)
Time=88425 ms [0.1x]

Original original

Expected more or less like sox-v-ns-shibata-low

Fact resampler

Originally posted by @sergeevabc in https://github.com/jniemann66/ReSampler/issues/34#issuecomment-1963090848

jniemann66 commented 8 months ago

Hey Thanks for this. It seems as though the unusual input sampling rate (54321 Hz) results in ReSampler not choosing the correct arrangement / parameters for the individual conversion stages (ie the LPF filter params are not sufficient; resulting in the severe aliasing you are seeing there).

I will have a look at it when I get a chance. (Also, I need to build and release latest binaries for Windows.)

Have you tried it with the --singleStage option ? what happens ?

Thanks. Regards Judd

sergeevabc commented 8 months ago

Have you tried it with the --singleStage option ? what happens ?

The situation is not changing for the better, Judd, but I believe you can fix it.

jniemann66 commented 8 months ago

Well, with the traditional interpolation / decimation process, and with a conversion ratio of 14700:18107, it is necessary to stuff 14700 zeros for every input sample, apply LPF and then capture (decimate) every 18107th sample !

To do this properly, a really large FIR is required, and IIRC, I set a hard limit on how big the FIR filter can be (max 131071 taps), which is usually more than sufficient for "normal" sample rates. So, for more exotic samplerates like this, I will probably need to look at a different approach.

but 54321 is pretty weird though :-) Is there actually a device that can do that sample rate ? I'm curious. I'm aware that in the early days of the development of CDs, there was at one point a proposed sample rate of 44056 Hz. I have never come across an authentic 44056 Hz file, but if you ever find one, I'd be very interested to check it out.

And yes, I do believe ReSampler will struggle with 44056, too.

I'll see what I can do.