Preliminary results of libsoxr integration
Plugin rate API modified to allow float. This avoids the information loss of int24->int16 conversion currently occuring in alsa-lib (int24->float32 is bit perfect). Libsamplerate (and libsoxr) use float internally.
The sweep file generated by:
sox -V -r 44100 -c 2 -s -b 24 -n sweep.wav synth 10 sine 1:22000 vol -6dB
Spectrum of the sweep
sox sweep.wav -n spectrogram -w Kaiser -z 180 -o spectrum-sweep.png
Devices defined in .asoundrc:
pcm.raw {
type hw
card 0
device 0
format S32_LE
}
pcm.flexibleraw {
type plug
slave.pcm raw
}
pcm.dumpratefile {
type file
#slave.pcm flexibleraw
slave.pcm null
file /home/pavel/output.wav
format wav
}
pcm.rate192 {
type rate
slave {
pcm dumpratefile
rate 192000
}
converter "samplerate_best"
#converter "speexrate_medium"
}
Rate conversion using regular libsamplerate:
time aplay -v -D rate192 sweep.wav
...
real 0m13.162s
user 0m12.905s
sys 0m0.116s
Uff, 12 seconds of CPU spent converting a 10 second piece.
But the spectrum looks OK:
Rate conversion using libsoxr-lsr (replacing the libsamplerate), samplerate_best:
time aplay -v -D rate192 sweep.wav
...
real 0m1.650s
user 0m1.572s
sys 0m0.048s
There are visible errors, will be fixed, but the spectrum looks even better IMO:
And the CPU load is almost ten times lower 🙂
Time to fix the plugin code now to avoid the distortion.
It may be advantageous to test with different signals in left and right channels, e.g. synth 10 sine 1:22000 sine 22000:1