Use high-quality codec and microphone simultaneously with Bluetooth headset

24,080

Solution 1

A2DP is not a bidirectional profile. So it will not get bi-directional audio.

What you want is something like the mSBC codec over HFP profile.

There is a good article here that explains how to use it on Ubuntu 20.04 with pipewire instead of PulseAudio. It even includes a recording soundclip, and a playback soundclip (which was created by recording, with a mic the sound from the headset), to show the difference in quality.

Solution 2

Based on this answer https://askubuntu.com/a/1250010/35326 it looks like A2DP bi-directional audio will not work until Linux kernel and PulseAudio are improved to support this.

Solution 3

You might be able to do this with PipeWire instead of PulseAudio.

Comment from Ric @tornado99:

On arch-based distros:

  1. uninstall pulseaudio-bluetooth
  2. force uninstall just pulseaudio without removing any dependencies, so sudo -Rdd pulseaudio
  3. install pipewire and pipewire-pulse
  4. edit /etc/pipewire/media-session.d/bluez-monitor.conf to allow mSBC
  5. make sure you are running kernel 5.8+
  6. check it works i.e. select HSP profile, and then you can use headphones+mic on your device with reasonable-sounding audio (16kHz)
  7. if you get silence, you need to switch to a Realtek RTL8761B-based USB receiver. these are very cheap (mine was branded Maxesla Bluetooth 5.0)
  8. install firmware file for RTL... (just do a web search)
  9. enjoy!
Share:
24,080

Related videos on Youtube

user3188445
Author by

user3188445

I'm in the computer security field and have been using C and Unix since before 1990. I have extensive development experience in C++ and Haskell. For C++, I hate boost, and so do everything either directly on the standard library or using my own templates. I write a lot of bash and emacs lisp, too, and at a previous stage of my career turned out a lot of perl (though I haven't used perl in years). I've dabbled in TeX and written some LaTeX classes used by others, but am far from an expert. I prefer the command line to all other interfaces, especially web browsers. I love git as much as I hate github. I try to write and use free software whenever possible, and have pretty much succeeded on the writing front but am sometimes forced into using proprietary systems (like the baseband on my phone).

Updated on September 18, 2022

Comments

  • user3188445
    user3188445 over 1 year

    I have various Bluetooth headsets, and when I use these with Android and ChromeOS, I get decent bidirectional audio quality for calls and video chats.

    Unfortunately, when I use them on my arch Linux laptop (with PulseAudio 13.99.2+13+g7f4d7fcf5-1, bluez 5.55-1, and pulseaudio-modules-bt 1.4-3), I have a choice (under the pavucontrol configuration panel, or using pactl set-card-profile): I can enable high quality sound using A2DP with a nice selection of codecs including SBC, AptX, and AAC, or I can enable the microphone using HSP/HSF instead of A2DP. With the HSP/HSF profile, the microphone "works" in the sense that there is bidirectional audio with both a source and sink in PulseAudio, but the sound quality is so bad that it can be hard to understand the words people are saying.

    My questions are:

    1. What is actually happening when Android or ChromeOS gets decent sound quality with the mic enabled? Is it possible to use a decent codec in HSP/HSF mode? Is it possible to use a mic with A2DP? Or is there some other Bluetooth mode?

    2. On the pulseaudio-module-bt web site, all of the codecs except LDAC seem to support decoding as well as encoding, but how do I actually use the decoding functionality? Is this only for using my laptop as a virtual headset for another device, or is there a way to use these codecs for the microphone of a Bluetooth headset?

    3. What concrete steps can I take to make my headset sound better in bidirectional calls? Or failing that, even if the microphone sounds bad, can I at least make the speakers sound good without completely disabling the microphone?

    Update

    Well, I don't fully understand this, but it seems that maybe good sound quality requires at least HFP 1.6, and bluez currently does not support HFP because doing so requires breaking backwards compatibility with oFono, which has become a contentious question.

    Until this has been sorted out, I worked around the problem by getting an Avantree DG80 Bluetooth audio dongle. It looks like an ordinary USB audio device in Linux but pairs with my headsets. The sound quality isn't as good as A2DP, but is noticeably better than what I was getting out of bluez/PulseAudio. It's also nice that I can switch between the A2DP and HSP/HSF modes either by switching between stereo and stereo+mono input in PulseAudio, or by double-tapping the switch on the front of the Bluetooth dongle.

  • Trying to do great things
    Trying to do great things about 2 years
    PipeWire also supports automatic profile switching, see this askubuntu.com/a/1397581/92428 for details.
  • Admin
    Admin about 2 years
    Actually this is not correct. A2DP is a bluetooth profile, that does not specify Bi-directional audio. So saying "It will not work until Linux kernel and PulseAudio are improved to support this" Is only correct in that it will NEVER support it on A2DP. What you want is a high quality codec via HFP. such as mSBC.