My newly purchased set of earbuds had terrible microphone quality in video-conferencing only on my Ubuntu system. The problem was that most earphone/earbuds use A2DP configuration for High Fidelity Playback. This configuration doesn’t support mic as it works unidirectionally (Laptop to Earbuds only). Switching this configuration to HSP/HFP can enable mic support with minor degradation of audio/output quality. This configuration is not available by default in Ubuntu using Pulseaudio drivers. The Pulseaudio drivers that comes pre-loaded with the OS has removed the support for HSP/HFP due to it’s buggy nature. This lead to removed support for mic on most wireless earbuds. To solve the issue of wireless earbuds not working you can jump to ‘Solving The Issue’ section or you can read how I reached to this conclusion below.
I recently bought a pair of wireless earbuds that boasted of having 4 microphones for loud and clear call quality. This claim indeed held true on multiple phone calls done using my mobile over the next weekend. The person on other side of the call could definitely hear me better than any of my previous earphones/buds. The problem started when I tried to pair it with my laptop for video conferencing. Surprisingly! the compliments of crystal clear sound from my phone calls suddenly turned into complaints of too much noise on my laptop.
Since everything was working fine on my phone, it didn’t took me long to figure out that the problem was with the Ubuntu system. To dig a bit deeper, I looked into Settings panel under Bluetooth section, nothing much to see there. The only option I got was to disconnect the device or forget connection. No leads so far! Next, I shifted my focus to the Sounds section, to check if there is some problem with my microphone configuration. Voila! there it is, the problem stared right at my face. The output was configured to use my earphones but the input/mic was locked to the laptop’s microphone and the earbud’s mic was not even listed.
The Root Cause
So finally, I got to the problem, half the battle won right? not so fast the problem was not just the missing driver but the missing support. Let’s explore the situation a bit more, the configuration on output was set to A2DP but input is locked to digital microphone. So maybe, if I can somehow add the same configuration for microphone as well, things might work? The answer I got was a huge NO! A2DP only support unidirectional audio transfer and is used to send High Fidelity Playback audio to earbuds. It cannot simply send input from the mic to the laptop.
So this configuration will not work with the on-device microphone. Simply searching ‘Ubuntu mic not working’ brings up only few relevant results, none of them worked completely at the time of writing this. But while searching on our beloved Stack Overflow there are many dead ends for “wireless earbuds not working”. After searching for a while I got another lead or configuration to be precise. HSP (Head Set Profile) or HFP (Head Phone Profile) configuration which supports bi-directional data transfer is required if we want to use the microphone of any Bluetooth device. Support for this configuration was removed in previous versions of Pulseaudio due to the buggy nature of the library. The oFono library that adds support for mobile telephony was used for HSP/HFP configuration in earlier version of Pulseaudio. So I finally reached to the root cause of the problem now time to find the solution.
Solving The Issue
Originally, when I started writing this article, it was going to be about oFono. It added support for HSP/HFP to the existing Pulseaudio drivers instead of replacing them. Though, I had previously heard about another solution named Pipewire. Being an alternative to Pulseaudio, I had to remove the existing drivers and install the Pipewire for it to work. But the idea of replacing the drivers for adding support sounded a bit too extreme at that time. So oFono was my only option left at that time and it did work (for at least a few minutes).
oFono as already mentioned is a bit buggy and that’s why it was removed from Pulseaudio. In my initial testing I was happy with it until it started randomly disconnecting the audio. It was not at all reliable and I had to write system services/configs to get it to work seamlessly. It was just a lot more effort with very little Output. After a 2 days of struggling with this setup, I finally decided to try out Pipewire. After all, being a Software Developer, I cannot leave a problem unsolved, even if it means having to install the drivers again if things go wrong. So far the experience with Pipewire is far better than oFono + Pulseaudio. So, it is the recommended setup from my side to solve the issue of wireless earbuds not working.
Pipewire is an Open Source utility that supports HSP/HFP configuration out of the box. This utility simply replaces the pre-installed Pulseaudio utility without uninstalling it completely. This gives the added advantage of rolling back your changes if things go wrong at any point. Let’s get to the part on how to set it up on your Ubuntu 20 computer.
- Open the terminal. You can hit `Ctrl+Alt+T` or look for terminal in global search.
- In the terminal run the following command to add the Pipewire package source to your source list:
sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
- Run the update command to refresh the PPA in the system:
sudo apt update
- Install Pipewire by simply running the command:
sudo apt install pipewire
- Install Pipewire with all dependencies using the command:
sudo apt install libspa-0.2-bluetooth pipewire-audio-client-libraries
sudo apt install gstreamer1.0-pipewire libpipewire-0.2-1 libpipewire-0.2-dev libpipewire-0.2-doc
- Reload the daemon:
systemctl --user daemon-reload
- Next we will disable Pulseaudio from the system (we are not removing it just disabling):
systemctl --user --now disable pulseaudio.service pulseaudio.socket
systemctl --user mask pulseaudio
- Restart your system before moving to the next step. Since we have disabled the Pulseaudio service that was pre-loaded in OS, it is crucial that we restart the system. This step help in proper configuration of the new service.
- Enable the Pipewire media session service:
systemctl --user --now enable pipewire-media-session.service
- Test your install by running the following command:
If the text that appears say ‘Pulseaudio (on Pipewire)‘ under server name then your installation is successful else you can try the bellow command to restart the Pipewire serve and check again:
systemctl --user restart pipewire
Do note that in HSP/HFP configuration the earbuds will work in mono mode (Stereo only works with A2DP configuration).
If you want to rollback all the changes we did just now, you can do it by using:
systemctl --user unmask pulseaudio
systemctl --user --now enable pulseaudio.service pulseaudio.socket
Post Installation Steps (Optional)
After installing Pipewire the connectivity was great but the input volume from the mic was very low. I was barely audible to the other participants (again only happening on Ubuntu). If you face similar issue after installing Pipewire, you can simply install PulseEffects. It’s an audio utility that allow you to change (and boost) the input/output of your system audio. And a cherry on top is that it can also remove the low frequency noise using preset filters. Here is how you can install and configure PulseEffects in your system:
- Just like we did for Pipewire, we will simply add the PPA for the PulseEffects package to the system:
sudo add-apt-repository ppa:mikhailnov/pulseeffects -y
- Next install the utility with ‘–install-recommends’ flag to also install any required dependencies:
udo apt install pulseeffects --install-recommends
- Open PulseEffects and change the configurations by adding audio effects. Below is the configuration that worked for me (your values might vary).
- Limiter: Change Input to 30.0, leave rest of the settings unchanged.
- Multiband Compressor: Change input to 2.5, leave everything else unchanged.
- Filter (for additional noise reduction): Select ’12db/oct Bandpass’ from presets, change Resonance to -1.0 dB, leave everything else unchanged.
- Equalizer: Change input to 2.5, leave everything else unchanged.
You can test out different configurations and check it on any online mic test utility (Google ‘mic test’). These utilities record your voice from your microphone. Once done you can playback the sound to check audio quality. In my case with these settings the voice is loud and clear.
Drop a Like if you think this was helpful. Share with others if someone else is facing this issue. Leave a comment If something in this article didn’t work. You can also share what worked for you in the comments.
If you happen to host a WordPress website, you can read how to secure your site:
Signing off till next article, See you there 🙂