This guide will help you connect your Sony WH-1000XM4 headset to Ubuntu 22.04 using Bluetooth. Once connected, you'll be able to listen to music and use the microphone on apps like Microsoft Teams.
-
Open a terminal and launch
bluetoothctl
:bluetoothctl
-
Initialize the agent and set it as the default:
agent on default-agent
-
Scan for Bluetooth devices:
scan on
Look for the MAC address of your Sony WH-1000XM4 headset.
-
Stop the scanning process:
scan off
-
Pair, trust, and connect to the headset using its MAC address:
pair XX:XX:XX:XX:XX:XX trust XX:XX:XX:XX:XX:XX connect XX:XX:XX:XX:XX:XX
(Replace
XX:XX:XX:XX:XX:XX
with the MAC address of your headset.) -
Exit
bluetoothctl
:exit
Ubuntu 22.04 partially uses PipeWire by default. To fully utilize it for audio and Bluetooth, follow these steps:
- Install and start WirePlumber:
sudo apt install pipewire-media-session- wireplumber systemctl --user --now enable wireplumber.service
-
For ALSA:
sudo apt install pipewire-audio-client-libraries sudo cp /usr/share/doc/pipewire/examples/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/
-
For Bluetooth:
sudo apt install libldacbt-{abr,enc}2 libspa-0.2-bluetooth pulseaudio-module-bluetooth-
After rebooting your system, you can check if PipeWire is active by running:
LANG=C pactl info | grep '^Server Name'
mkdir -p ~/.audio/bin && cd ~/.audio/bin
wget https://gist.githubusercontent.com/peters/26315cd7a8a31e3d192ed05ef9a79ba7/raw/9466f91da19b53d01cac862898cfdfcb18e3137e/wh1000xm4-audio-profile.sh
chmod +x wh1000xm4-audio-profile.sh
./wh1000xm4-audio-profile.sh
For microphone testing, click here to visit the microphone test site
Hi!
Thank for the description.
What I don't understand is why the profile changes? In A2DP in theory you would use ldac but in headset profile you get the poor quality audio BUT you would get mic. Using LDAC wouldn't allow for both?
On Android devices in theory both high quality audio and microphone usage. here chatgpt about it:
"
Android supports audio codecs like aptX and LDAC and advanced Bluetooth profiles that allow simultaneous high-quality audio playback and microphone usage. This is because Android has more flexibility in managing Bluetooth connections compared to Windows, which uses legacy drivers and profiles for compatibility.
"
edit: some chatgpting
okay so chatgpt:
The Bluetooth protocol and available profiles have bandwidth limitations. Here's why:
Bluetooth Bandwidth: Bluetooth operates in a constrained bandwidth environment (~1-3 Mbps depending on codec and connection quality).
Profile Limitations:
A2DP (Audio Streaming): Focuses on high-bitrate audio for playback, consuming most of the available bandwidth.
HFP/HSP (Microphone + Audio): Allocates bandwidth for bidirectional communication, which reduces audio playback quality to ensure reliable voice transmission.
Codec Limitations:
Codecs like LDAC, aptX-HD, and AAC optimize one-way audio quality but aren’t designed for two-way communication.
HFP with mSBC improves audio but is still limited to 16 kHz sampling, far below LDAC’s 96 kHz.
Can PipeWire Improve Both?
With PipeWire, you can balance the tradeoff more effectively:
Enable mSBC Codec in HFP:
Provides better microphone quality compared to standard HFP (8 kHz sampling).
Playback quality also improves but is still not comparable to A2DP.
Dynamic Profile Switching:
PipeWire can dynamically switch between A2DP for high-quality playback and HFP/HSP when the mic is in use.
This reduces interruptions and may provide a seamless user experience for applications like gaming or calls.
hardware limitations etc. etc.
PC Bluetooth Stack: Unlike Android, which uses customized Bluetooth implementations, Linux (and Windows) rely on generic stacks, limiting flexibility.