ReSampler icon indicating copy to clipboard operation
ReSampler copied to clipboard

Testing quad precision in resampling DSD to PCM

Open klassikmann opened this issue 4 years ago • 3 comments

TL;DR The experimental quad precision version of ReSampler is incredibly slow in resampling DSD64 to 24bit/96kHz.

Background and History (2017-2019) My MPD based audio player is digitally connected via TOSLINK (i.e. no DAC in the signal path) to active loudspeakers (Genelec 8351A) accepting PCM only, no DSD. The input stage of the Genelecs is separating (and resampling) the signal to 24bit/96kHz for the tweeter and to 24bit/48kHz for the midrange and woofer. To playback my DSD collection I resampled DSD64 to PCM applying the "natural" (?) 24/88.2 format. Therefore the Genelecs had to perform the complex 88.2->96 resampling in real-time but I could hear audible artifacts in some pieces of classical music. So I decided to resample my DSD collection to 24/96 using the DSD-enhanced SoX by Måns Rullgård and XiSRC by xivero (now out of business). Redbook compliant material (16/44.1) is resampled to (24/48).

Testing ReSampler Starting end of last year I'm using ReSampler for the (16/44.1) -> (24/48) conversion. I'm compiling ReSampler from source on Ubuntu 20.04 in two "flavors", as AVX+FMA and as the (experimental) quad precision. Test input is a DSF of nearly 20 minutes of classical music.

Test 1: Single precision (flags: -r 96000 -b 24 --mt --multistage) 2.0.9 64-bit version AVX build ... using FMA (Fused Multiply-Add) instruction ... Input file: 1.dsf Output file: 1.flac Changing output bit format to 24 Changing output file format to flac source file channels: 2 input sample rate: 2822400 output sample rate: 96000 LPF transition frequency: 43636.36 Hz (90.91 %) Conversion ratio: 0.034014 (5:147) Writing Metadata Converting (multi-stage, multi-threaded) ... Writing to output file ... Done Peak output sample: 0.560189 (-5.033305 dBFS) Time=154000 ms [7.7x]

Test 2: Double precision (flags: -r 96000 -b 24 --doubleprecision --mt --multistage) 2.0.9 64-bit version AVX build ... using FMA (Fused Multiply-Add) instruction ... Input file: 1.dsf Output file: 1.flac Changing output bit format to 24 Changing output file format to flac Using double precision for calculations. source file channels: 2 input sample rate: 2822400 output sample rate: 96000 LPF transition frequency: 43636.36 Hz (90.91 %) Conversion ratio: 0.034014 (5:147) Writing Metadata Converting (multi-stage, multi-threaded) ... Writing to output file ... Done Peak output sample: 0.560190 (-5.033286 dBFS) Time=189979 ms [6.3x]

Test 3: Quad precision (flags: -r 96000 -b 24 --mt --multistage) 2.0.9 64-bit version Input file: 1.dsf Output file: 1.flac Changing output bit format to 24 Changing output file format to flac Using quadruple-precision for calculations. source file channels: 2 input sample rate: 2822400 output sample rate: 96000 LPF transition frequency: 43636.36 Hz (90.91 %) Conversion ratio: 0.034014 (5:147) Writing Metadata Converting (multi-stage, multi-threaded) ... Writing to output file ... Done Peak output sample: 0.560191 (-5.033284 dBFS) Time=8970719 ms [0.1x]

klassikmann avatar May 27 '20 08:05 klassikmann

Hi Klassikmann - I'm impressed that you tried the quad-precision version - you Mad lad !! Unfortunately, the speed of quad-precision is never going to be great unless one day we have a CPU that does quad precision in hardware - until then, the 128-bit quad-precision operations need to be "simulated" in software.

Nevertheless, there might be some things that can be done to speed it up a bit. I haven't really tested DSD with quad-precision much - I didn't think there would be much interest in doing so, but you appear to have contradicted that little assumption :-) , so maybe there are some optimization opportunities lurking in the shadows.

I'll have a look into it when I get a chance - absolutely flat-out atm. Can't promise anything, but who knows ? might be able to squeeze some more out of it - should be able to do better than 0.1x at any rate.

Cheers Judd

jniemann66 avatar May 27 '20 10:05 jniemann66

Hi Judd,

thank you for your immediate feedback.

You're right, I'm testing quadruple-precision out of pure curiosity. Double-precision is more than enough for real life. The slowness of quad-precision seems to be appear in DSD->PCM conversion only.

Here a test result resampling PCM 16/44.1 (46'44") to 24/48: Single-Precision (-r 48000 -b 24 --mt --multistage): Time=101819 ms [27.5x]

Double-Precision (-r 48000 --doubleprecision -b 24 --mt --multistage): Time=104067 ms [26.9x]

Quad-Precison (-r 48000 -b 24 --mt --multistage): Time=91972 ms [30.5x]

Quad-precision seemed to be the fastest.

Regards Herbert

klassikmann avatar May 27 '20 10:05 klassikmann

Ok - Thanks for that. There might be something going wrong with DSD conversion in Quad precision - I'll try to check it out on the Weekend

jniemann66 avatar May 27 '20 12:05 jniemann66