How to enable AptX for Bluetooth devices?
The answer here doesn't go over HOW to enable AptX if you have a compatible AptX dongle.
Since I can not mark this as a duplicate:
The accepted answer to the linked question added the answer to this "question" as well. The linked github project https://github.com/EHfive/pulseaudio-modules-bt adds support to pulseaudio for aac, aptx, aptx hd and ldac codecs.
Due to licensing issues, it can not be merged upstream. However, an Ubuntu ppa is supplied: https://github.com/EHfive/pulseaudio-modules-bt/wiki/Packages#ubuntu-1804-1810-1904
For future reference:
First the PPA needs to be installed. This can be done with the following for Ubuntu 18.04, 18.10, 19.04:
sudo add-apt-repository ppa:eh5/pulseaudio-a2dp
sudo apt-get update
sudo apt-get install libavcodec58 libldac pulseaudio-modules-bt
If you have newer Ubuntu versions, instead, the correct code is the following:
sudo add-apt-repository ppa:berglh/pulseaudio-a2dp
sudo apt update
sudo apt install pulseaudio-modules-bt libldac
Now you need to restart pulseaudio:
pulseaudio -k
pulseaudio --start
I then had to reconnect my headphones (Sennheiser HD 4.50 BTNC), and set them as audio sink. In the sound settings, AptX was already displayed. Selecting AAC/AptXHD/LDAC didn't change what was used (due to my headphones only supporting AptX). To check on the shell:
pactl list sources | grep a2dp_codec
The above has no output when used without the custom modules!