Creating a stereo virtual sound output device with 2 bluetooth speakers separately connected via bluetooth

How to create a bluetooth stereo virtual output device with two bluetooth speakers separately connected via bluetooth to the PC ?

My PC gets two Amazon Echo Pop connected separately via bluetooth

Each Echo Pop is seen by bluetooth as a stereo ouput device with a left and right channel.

  1. Procedure

create a virtual stereo device named “bluetooth_stereo”

pactl load-module module-null-sink media.class=Audio/Sink sink_name=bluetooth_stereo channel_map=stereo

link the left channel of the PC to the left channel of the left Echo Pop (named “Gauche” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FL bluez_output.<mac_address_1>:playback_FL

link the left channel of the PC to the right channel of the left Echo Pop (named “Gauche” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FL bluez_output.<mac_address_1>:playback_FR

link the right channel of the PC to the right channel of the right Echo Pop (named “Droite” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FR bluez_output.<mac_address_2>:playback_FR

link the right channel of the PC to the left channel of the right Echo Pop (named “Droite” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FR bluez_output.<mac_address_2>:playback_FL

see the helvum graphic

  1. Creating the device when logging

the device disappears when you log out or you restart the PC.

you must create it for each kde logging.

For this :

  • you must create a script with this contents :

#!/bin/bash

sleep 30s

#create a virtual stereo device named “bluetooth_stereo”

pactl load-module module-null-sink media.class=Audio/Sink sink_name=bluetooth_stereo channel_map=stereo

#link the left channel of the PC to the left channel of the left Echo Pop (named “Gauche” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FL bluez_output.7C_ED_C6_AF_FE_1B.1:playback_FL

#link the left channel of the PC to the right channel of the left Echo Pop (named “Gauche” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FL bluez_output.7C_ED_C6_AF_FE_1B.1:playback_FR

#link the right channel of the PC to the right channel of the right Echo Pop (named “Droite” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FR bluez_output.7C_ED_C6_B8_7C_78.1:playback_FR

#link the right channel of the PC to the left channel of the right Echo Pop (named “Droite” as a bluetooth device)

pw-link bluetooth_stereo:monitor_FR bluez_output.7C_ED_C6_B8_7C_78.1:playback_FL


There is a delay for, at logging, connecting the bluetooth speakers and then appearing as sound output devices.
Creating the virtual device needs that the bluetooth speakers are already created as sound output devices.
Then you need to execute the script after. Then you need a delay. Adjust it to your need.

  • you must add the script as a logging script in kde “automatical start”

At logging, according to connect automatically the bluetooth speakers to the PC, you must record the bluetooth context. For this, restart the PC.

Too many problems :
randomly

  • cracks
  • only left channel
  • only right channel
  • a good stereo

bluetooth, bluez, pipewire are not mature for this.

The answer from pipewire :

Two devices on same BT adapter can have problem with data transfer bandwidth. Debug log would if this is the problem.

In principle SBC has adjustable data rate, but Pipewire does not allocate it fairly for two devices, which maybe is the problem.

With A2DP you also have problem with playback synchronization.
Latency can vary for each connection and change slightly with time, and be different for the two speakers. Human stereo perception needs accuracy <1ms, it may be hard to reach that. The protocol does not support any synchronization between devices. (This is solved in LE Audio.)
TWS earbuds work differently: one earbud receives audio via A2DP and then sends it to the other device via custom protocol.

1 Like