Like any proper aficionado of moderately forgotten John Cusack movies, I appreciate some High Fidelity. Living in modern times, convenience is also a factor. I’d love to roll around with a set of Sennheiser open cans, but the cables and the noise leakage are disruptive. So after watching MKBHD express ambivalence over the newest Cupertino creation I also noticed how nice the Sony WH-1000XM4 started to look.
Active noise cancellation, decent audio quality, comfort, touch controls, and the glorious freedom from wires. It’s a Christmas present to myself. But the default audio quality under Linux just wasn’t great. Turns out I was listening to the fallback audio option for Bluetooth, SBC. SBC is sort of the basic fallback for Bluetooth audio when better options aren’t available. It’s required in order to support the A2DP standard. There are much better options, but they all come with caveats. AAC, LDAC, and aptX are the options, and each of them is patent encumbered. Because of this, Windows does not natively support any of them. In order to use any of these codecs you would need to have a hardware device that natively does the conversion. No doubt this is due to legal and licensing issues that would rustle the legal jimmies up in Redmond. Linux, however, ever respects your freedom and with a little patching will happily run any of them.
So let’s get out the old command line and cook up some audiophile goodness.
Linux audio system pulseaudio is pluggable, extensible, and generally quite good. Distributions ship with a version of the bluetooth modules that won’t step on any patent toes. A bit of Github code can extend functionality.
On Debian I had to install some dependencies first.
sudo apt install libavcodec58 libavcodec-extra libavcodec-extra58 libfdk-aac2 ffmpeg pkg-config cmake libtool libpulse-dev libdbus-1-dev libsbc-dev libbluetooth-dev libavcodec-dev fdkaac libldacbt-abr-dev libldacbt-enc-dev libldacbt-enc2 libldacbt-abr2 bluez-hcidump pkg-config cmake fdkaac libtool libpulse-dev libdbus-1-dev libsbc-dev libbluetooth-dev libavcodec-dev git checkinstall libfdk-aac2 libfdk-aac-dev
Pull down our module code and build it.
git clone --recurse-submodules https://github.com/EHfive/ldacBT.git
cd ldacBT/
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_LIBDIR=/usr/lib -DLDAC_SOFT_FLOAT=OFF ../
checkinstall -D --install=yes --pkgname libldac
cd ..
git clone --recurse-submodules https://github.com/EHfive/pulseaudio-modules-bt.git
cd pulseaudio-modules-bt
mkdir build
cd build
cmake ..
make
sudo make install
pulseaudio -k
sudo systemctl restart bluetooth.service
Now you can choose any of the codecs for use. I’m sticking with AAC, as it’s supported by my Sony headset and sounds delicious.