How to make aptX-capable Bluetooth equipment work with Ubuntu?

Update for 2021: PulseAudio supports AptX, LDAC - https://9to5linux.com/pulseaudio-15-0-released-with-support-for-ldac-and-aptx-codecs-improved-hardware-support

Edit 2018-10-27: LDAC, APTX(-HD) and AAC support for PulseAudio are in the works. There is a repository on GitHub by EHfive with patches as well as a PPA for 18.04 onward, check the Wiki for more information. It looks like the patches will arrive upstream at some point in time. I checked the PPA on 18.04, it works, though it replaces PA 11.1 with 12, installs a newer version of ffmpeg and x265.

  • Are PPAs safe to add to my system and what are some "red flags" to watch out for?

Edit 2017-12-18: I must have missed it a few weeks ago, but it looks like there is an encoder now in FFmpeg. To my knowledge no user friendly solution exists at the moment.

The short answer

You have to use special branded Bluetooth dongles. Have a look at the How can I use aptX then? section of this answer or browse the aptx.com site for transmitters.


The longer answer

Licensing issues

The aptX codec is proprietary standard, that CSR acquired from APT Licensing Ltd. with the goal to develop and market aptX powered high fidelity Bluetooth audio solutions via ingredient branding. You are correct, this is a strategy for CSR to sell exclusive chips.

I found the following clause when looking through the decoder license agreement:

  • Implement the Software as firmware in secure code embedded in the Licensee Product

While this does not answer questions about the encoder, I would say that the situation is at least as difficult as with other proprietary codecs and software components (1, 2, 3).

How can I use aptX then?

You can use it, just not as a free software solution.

You can find special branded Bluetooth dongles, so called aptX Transmitters. These are not the typical nano or pico-sized Bluetooth dongles, but USB Audio Class devices. (Have a look at the device classes section on the USB article in Wikipedia for more information.) This means that these devices will be recognized as sound cards and will not provide Bluetooth connectivity to the host computer. There is also one major downside: they cost almost 10 times as much as regular Bluetooth dongles.

List of aptX Transmitters or Bluetooth dongles with aptX support in alphabetical order:

  • Creative BT-D1 USB Bluetooth Transmitter, Bluetooth 2.1 + EDR
  • Creative BT-W1/BT-W2 USB, Bluetooth 2.1 + EDR
  • Sennheiser BTD 500 USB, Bluetooth 3.0
  • Avantree BTDG-50-WGR, Bluetooth 4.1 with aptX LL
  • 1mii B10, Bluetooth 5.0 with aptX LL, via AskNoah, ASINs: B083TD9VW4 (US), B086KXR1CF (DE)
  • Avantree DG80, Bluetooth 5.0 with aptX LL
    • Looks similar to 1mii B10 and probably is. Turned up as sponsored Amazon search result. I'm going to test both, particularly with two Nest Audio in stereo mode which at the moment have a 1s delay that I had to adjust in PulseAudio.

Check the configured codec of a connection

Install bluez-hcidump and run sudo hcidump avdtp, then connect the device and look for the configuration negotiation. The following this is the result I got (see also), it looks like it tried aptX, AAC and finally settled for SBC.

$ sudo hcidump avdtp
HCI sniffer - Bluetooth packet analyzer ver 5.35
device: hci0 snap_len: 1500 filter: 0x400
< AVDTP(s): Discover cmd: transaction 11 nsp 0x00
> AVDTP(s): Discover rsp: transaction 11 nsp 0x00
    ACP SEID 5 - Audio Sink
    ACP SEID 3 - Audio Sink
    ACP SEID 1 - Audio Sink
< AVDTP(s): Capabilities cmd: transaction 12 nsp 0x00
    ACP SEID 5
> AVDTP(s): Capabilities rsp: transaction 12 nsp 0x00
    Media Transport
    Media Codec - non-A2DP (aptX)
      16kHz 32kHz 44.1kHz 48kHz 
      Stereo 
< AVDTP(s): Capabilities cmd: transaction 13 nsp 0x00
    ACP SEID 3
> AVDTP(s): Capabilities rsp: transaction 13 nsp 0x00
    Media Transport
    Media Codec - MPEG-2,4 AAC
      MPEG-2 AAC LC MPEG-4 AAC LC 
      8kHz 11.025kHz 12kHz 16kHz 22.05kHz 24kHz 32kHz 44.1kHz 48kHz 
      1 2 Channels
      320000bps VBR
    Content Protection
      02 00 
< AVDTP(s): Capabilities cmd: transaction 14 nsp 0x00
    ACP SEID 1
> AVDTP(s): Capabilities rsp: transaction 14 nsp 0x00
    Media Transport
    Media Codec - SBC
      16kHz 32kHz 44.1kHz 48kHz 
      Mono DualChannel Stereo JointStereo 
      4 8 12 16 Blocks
      4 8 Subbands
      SNR Loudness 
      Bitpool Range 2-53
    Content Protection
      02 00 
< AVDTP(s): Set config cmd: transaction 15 nsp 0x00
    ACP SEID 1 - INT SEID 1
    Media Transport
    Media Codec - SBC
      44.1kHz 
      JointStereo 
      16 Blocks
      8 Subbands
      Loudness 
      Bitpool Range 2-53
> AVDTP(s): Set config rsp: transaction 15 nsp 0x00
< AVDTP(s): Open cmd: transaction 0 nsp 0x00
    ACP SEID 1
> AVDTP(s): Open rsp: transaction 0 nsp 0x00
< AVDTP(s): Start cmd: transaction 1 nsp 0x00
    ACP SEID 1
> AVDTP(s): Start rsp: transaction 1 nsp 0x00
< AVDTP(m): ver 2 cc 0 pt 1 seqn 0 time 0 ssrc 1
< AVDTP(m): ver 2 cc 0 pt 1 seqn 1 time 896 ssrc 1

Troubleshooting

  • A2DP only streams audio in one direction, for phone calls use the HSP/HFP profiles.
  • If headphones or devices are not recognized or listed as output device for example in VLC, try switching to another sound card and back via sound settings. The devices should be recognized then.

What about Ubuntu Phone?

I don't know if Ubuntu on Phones will support this codec. CSR documents say that solutions are available for Android device manufacturers, so I assume it's up to the phone manufacturers to decide if and how. Of course Ubuntu Touch generally supports Bluetooth headsets and I was able to pair my Nexus 4 running Ubuntu with the headsets I tested.


My experience and tests

Bluetooth modules and dongles tested:

  • Desktop with nano Bluetooth 2.1 and 4.0 dongles, Lenovo T530 with built in module. - A2DP achieved almost the same quality level as the BTD 500 when playing music from FLAC files. Audio from movies was in sync with 14.04.
  • Sennheiser BTD 500 USB. - Pairing takes as long as with regular non-NFC capable dongles.

Headsets tested:

  • Philips Fidelio M1BTBL, Bluetooth 4.0. - Works fine with all dongles and modules.
  • Sony MDR-10RBT, Bluetooth 3.0, NFC. - Works fine with all dongles and modules.
  • Creative Sound Blaster EVO ZxR, Bluetooth 2.1, NFC. - This one had the best reception range of all the three, but couldn't connect to the BTD 500.

≥ 2021: with pipewire

Pipewire supports APT-X through libfreeaptx0.

To install it use the instruction of the pipewire-debian ppa, in summary:

sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
sudo apt install gstreamer1.0-pipewire libpipewire-0.3-{0,dev,modules} libspa-0.2-{bluetooth,dev,jack,modules} pipewire{,-{audio-client-libraries,pulse,media-session,bin,locales,tests}}
systemctl --user --now disable pulseaudio.{socket,service}
systemctl start --user pipewire-pulse.service
systemctl enable --user pipewire.service
systemctl --user mask pulseaudio

Pic of the additional codecs in KDE (for a device not supporting apt-X) additional codecs in KDE


Perhaps you don't need aptX - as there is sbc-xq

Recently the 'lifehack' sbc-xq has been added to linux. According to this blog

audio quality of SBC XQ is comparable to aptX HD.

Perhaps you want to give it a try. On my machine, I could choose between sbc and sbc-xq with the help of the blueman-manager.