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

68,787

Solution 1

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.

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.

Solution 2

≥ 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

Solution 3

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.

Share:
68,787

Related videos on Youtube

Csabi Vidó
Author by

Csabi Vidó

This is my AskUbuntu profile and most of my stuff here on StackExchange is tech-oriented. However I do have other hobbies and interests, you may find more about these in my other profiles on the network. I'm lwbt on Reddit and Telegram. I started with Ubuntu and Linux somewhere between 2006 and 2007. With the release of 08.04 I completely migrated away from Windows to Ubuntu and while this has been a few years ago I still consider myself fairly new to this topic and I know I can still discover something new and exciting everyday. The following listing is not to brag about hardware, I'm rather trying to reproduce issues and share experience. Custom built desktop computers with Intel HD graphics (dualscreen setup), Lenovo T530 &amp; T560 (touch) without discrete graphics (also run Windows 10), Chromebooks Lenovo N22 &amp; ASUS Flip C302 (with GalliumOS) Behringer FCA610 USB (PulseAudio multichannel configuration), JDS Labs C5D &amp; The Element, Bluetooth dongles and BT audio speakers and headphones Wacom Intuos 4 PTK-540WL HP 3005pr Port Replicator (works with proprietary DisplayLink driver) Aten CS1794 HDMI KVMP Switch Logitech TK820 and some unifying receiver mice …and some APC UPS

Updated on September 18, 2022

Comments

  • Csabi Vidó
    Csabi Vidó almost 2 years

    I have an aptX-capable headset and I want to use it to play music with the highest possible audio quality the headset can technically provide in Ubuntu. How can I do that?

    While A2DP supports a lot of codecs optionally and is extensible to support other manufacturer-defined codecs. AptX does not only boast to provide better audio quality than the competition, but also advertises to reduce delay to have lip sync audio when watching videos.

    Here are my questions:

    • How can I make aptX-capable Bluetooth equipment use this codec in Ubuntu?
      • What solutions are available?
    • How can I check and verify an established connection for the codec it uses?

    I'd like to point out, while this may look like a sponsored post, it is not. In my opinion FLAC and Opus should be the gold standard, but to my knowledge devices with support for these codecs aren't available right now.

  • pseudosavant
    pseudosavant almost 8 years
    How did you check if a device is actually connecting using aptX instead of SBC?
  • Mtl Dev
    Mtl Dev over 7 years
    Avantree also make one, model BTDG-50-WGR. No I dont work for them, it is just good information to know.
  • Jezor
    Jezor almost 7 years
    Out of curiosity and definitely not because I would never pay $40 for a freakin' dongle, nobody ever reconstructed the binary / created alternative that would connect like aptx that would be available in some shady places?
  • Csabi Vidó
    Csabi Vidó almost 7 years
    @Jezor I did not look in shady places because I didn't have this much interest or technical skill nor have I I been able to find anything about this back then. Maybe some people did, I don't know and I rather prefer an open source solution, as I have written. LDAC appears to make aptX obsolete and is more open as far as I know.
  • John G
    John G over 6 years
    Azio BTD-v401 also advertises aptX capability but I cannot comment on it's compatibility with Ubuntu or any linux for that matter.
  • Zaar Hai
    Zaar Hai over 5 years
    Tried BTD 800 that came with my Sennheiser Precense UC on my Ubuntu 16.04. It was indeed recognized as soundcard. The playback is slightly of a lower quality comparable to A2DP when using BT with the same earpiece. According to dongle led it uses SBC codec. However once I start using BTD 800 mic (not BT), the audio quality degrades severely, BUT it's still much better when using the earpiece with BT through HSP/HFP profile, AND the mic recording quality is MUCH better. So even without apt-x the dongle makes the difference for me.
  • marco
    marco about 4 years
    Things evolved a little, leaving the link for others as my research brought me here first. Ill report how well this works. github.com/EHfive/pulseaudio-modules-bt
  • Kat Amsterdam
    Kat Amsterdam about 4 years
    There are packages now that make the install of Apt-X a breeze in Ubuntu 18.04 github.com/EHfive/pulseaudio-modules-bt/wiki/Packages
  • marco
    marco almost 4 years
    HOUSON and BlitzWolf sell such adapters for 10+ bucks
  • Csabi Vidó
    Csabi Vidó almost 3 years
    Thanks for the info. My main concern these days is not audio quality but delay caused by SBC on some apparently more unusual setups like pairing two nest audio in stereo mode and using them as bluetooth desktop speakers. But that's a different topic.