Using libsoxr-lsr in Alsa Rate Plugin with LD_PRELOAD

Since my previous post the great libsoxr library incl. the libsoxr-lsr variant has become part of debian testing/ubuntu repositories. It means we can easily use it instead of libsamplerate now.

Just install the package:

pavel@samsung ~ $ aptitude search libsoxr
p libsoxr-dev - High quality 1D sample-rate conversion lib
p libsoxr-dev:i386 - High quality 1D sample-rate conversion lib
p libsoxr-lsr0 - High quality 1D sample-rate conversion lib
p libsoxr-lsr0:i386 - High quality 1D sample-rate conversion lib
p libsoxr0 - High quality 1D sample-rate conversion lib
p libsoxr0:i386 - High quality 1D sample-rate conversion lib

sudo aptitude install libsoxr-lsr0

Check contents of the package:

pavel@samsung ~ $ dpkg -L libsoxr-lsr0
...
/usr/lib/x86_64-linux-gnu/libsoxr-lsr.so.0.1.9
...
/usr/lib/x86_64-linux-gnu/libsoxr-lsr.so.0
...

Using the device rate192 (resampling to 192kHz using samplerate_best) from my previous post, on my samsung laptop:

time aplay -D rate192 sweep.wav
Playing WAVE 'sweep.wav' : Signed 24 bit Little Endian in 3bytes, Frekvence 44100 Hz, Stereo

real 0m10.060s
user 0m7.652s
sys 0m0.044s

Almost 8secs of CPU time for 10 secs playback on Intel i5.

Now let’s use libsoxr-lsr0 instead of libsamplerate, using the handy LD_PRELOAD method:

time LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libsoxr-lsr.so.0 aplay -D rate192 sweep.wav
Playing WAVE 'sweep.wav' : Signed 24 bit Little Endian in 3bytes, Frekvence 44100 Hz, Stereo

real 0m10.037s
user 0m0.652s
sys 0m0.040s

650ms is a way better figure 🙂

Unfortunately the spectrum test still reveals the (actually audible) cracks:

As you see the cracks appear only during the first seconds of playback. Hopefully in co-operation with authors of libsoxr this minor issue will be fixed soon.

Note: The noisy background compared to the dark black one of spectrograms shown in my previous post is caused by conversion down to 16 bits, still present in stock alsa library. I will post my patch to alsa-devel mailinglist.

This entry was posted in Linux Audio. Bookmark the permalink.

Comments are closed.