Playing bluetooth music sources through linux

This is not really a linux mint question but more general linux sound playing,

I look after the sound systems for our association, we have several boxes with bluetooth connection, so its simple connect and play, no problems.

But my question is about our main sound system, which is a mixing desk with built in amplifier. When i want to play music I plug the linux mint computer in and then use a headphone connection jack plug to plug into the mixing desk. Then use vlc or similar to play the music. No problem.

But more and more I am asked about connecting bluetooth to the mixing desk, there is no direct interface and dont really want to buy another box.

My linux mint computer has bluetooth no problem.

How do I connect a bluetooth device, to my linux box, which is then connected to the mixer. Then play the music, ?

Do I use file manager to see the device (telephone) and select play from that ?
Or do I open my play list on the phone and use that ?
How does it then transfer the music through bluetooth to the linux box, then play that through the amplifier
I can of course transfer everything from the phone directory into my linux box and cheat, but some of our users are phone happy, not computer box due to location. Phone in the hand, linux box on a desk away from them

Sorry hard to describe the connection issue.

Can you draw the signal path for me?
What exatctly do you want to achieve?

Reading your sentences makes me think you want to set up your Linux box as BT receiver which outputs the over the BT received sound to the mixing desk via jack/RCA output.
Is that the case?

Edit: you can surely do that with your Linux box, needs some configuration for pulseaudio/bluetooth, similar things you can find for Raspberry as BT receiver.

But!

Let me mention BLT2:

I bougth such a device for my son to use it as BT receiver in his Hifi setup, I can tell it works stable and flawlessly, the analog sound quality which it outputs is hugely better than what a laptop or a PC could output from an integrated soundcard.

Yes simply

No drawing tools as i am on my tablet.

But

Telephone → bt → linux mint → headphone output → audio cable jack → amplifier

Press play on phone hear sound on amp speakers.

2 Likes

OK, I understood correctly then :slight_smile:
Is by any chance the BLT 2 an option?
Or do you want to stick to involve Linux into the thing?

1 Like

Maybe I used a wrong word.

That’s a nice drawing of the signal path I meant


Maybe this is for you:

I have a similar setup, but with a Raspberry. When I’ll home, I can check the setup there I use, but there Pulseaudio runs as a system service, which is probably not what you want on your laptop


2 Likes

The basic requirement in the linux box is the bluetooth software. It is probably there in Mint, but check, the package is called ‘blued’. There may also be some management
app with a gui.
With just that you can connect with bluetooth to a phone.
I dont know about the rest, follow Laszlo.

1 Like

Because my association does not want to spend money 
 it best option which is free is always the selection.

I bought 2 connection cables this year less that 10 euros and it was like drawing blood !

Why do we have to pay, just make it work !
Technical problems are pauls domain to solve.

Typical reaction

But i appreciate your ideas which i will look further into

1 Like

Next week I’ll be near to my Raspberry (at home :slight_smile: )

Then I’ll look into it, and most probably I will be able to help you a bit more.

1 Like

Thanks that would be great.
No rush, we are almost at the end of our summer season so everything is sorted, its planning for next summer in my mind whilst i have time to test before the presure arrives.

2 Likes

https://www.reddit.com/r/linux/comments/g10h4k/pulseaudio_can_turn_your_computer_into_bluetooth/ maybe?

Mind you - that was 4 years ago, before PipeWire was so prevalent


2 Likes

The bluetooth on my RPi seems to be dead
 I did not use it since a while, so I don’t know what happened there, I’ll look into it.
But!
This one seems to work on my laptop. The original recype is for RPi with Pipewire, my laptop has now Debian with PW as sound server.
So slightly modified the recype.
If you have PW in your Linux box, this should work.
For me the dependencies were already installed, I did not need to apt install anything.

So what I did now (everything done as root, so append “sudo” before the commands if you do it from your regular user account):

  1. put this into /opt/pw-speaker, for example
    nano /opt/pw-speaker
#!/usr/bin/python3
# SPDX-License-Identifier: LGPL-2.1-or-later

import dbus
import dbus.service
import dbus.mainloop.glib
from gi.repository import GLib

BUS_NAME = 'org.bluez'
AGENT_INTERFACE = 'org.bluez.Agent1'
AGENT_PATH = "/speaker/agent"

A2DP = '0000110d-0000-1000-8000-00805f9b34fb'
AVRCP = '0000110e-0000-1000-8000-00805f9b34fb'

bus = None


class Rejected(dbus.DBusException):
    _dbus_error_name = "org.bluez.Error.Rejected"


class Agent(dbus.service.Object):
    exit_on_release = True

    def set_exit_on_release(self, exit_on_release):
        self.exit_on_release = exit_on_release

    @dbus.service.method(AGENT_INTERFACE,
                         in_signature="", out_signature="")
    def Release(self):
        print("Release")
        if self.exit_on_release:
            mainloop.quit()

    @dbus.service.method(AGENT_INTERFACE,
                         in_signature="os", out_signature="")
    def AuthorizeService(self, device, uuid):
        # Always authorize A2DP and AVRCP connection
        if uuid in [A2DP, AVRCP]:
            print("AuthorizeService (%s, %s)" % (device, uuid))
            return
        else:
            print("Service rejected (%s, %s)" % (device, uuid))
        raise Rejected("Connection rejected by user")

    @dbus.service.method(AGENT_INTERFACE,
                         in_signature="", out_signature="")
    def Cancel(self):
        print("Cancel")


if __name__ == '__main__':
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

    bus = dbus.SystemBus()

    agent = Agent(bus, AGENT_PATH)

    mainloop = GLib.MainLoop()

    # By default Bluetooth adapter is not discoverable and there's
    # a 3 min timeout
    # Set it as always discoverable
    adapter = dbus.Interface(bus.get_object(BUS_NAME, "/org/bluez/hci0"),
                             "org.freedesktop.DBus.Properties")
    adapter.Set("org.bluez.Adapter1", "DiscoverableTimeout", dbus.UInt32(0))
    adapter.Set("org.bluez.Adapter1", "Discoverable", True)

    print("RPi speaker discoverable")

    # As the RPi speaker will not have any interface, create a pairing
    # agent with NoInputNoOutput capability
    obj = bus.get_object(BUS_NAME, "/org/bluez")
    manager = dbus.Interface(obj, "org.bluez.AgentManager1")
    manager.RegisterAgent(AGENT_PATH, "NoInputNoOutput")

    print("Agent registered")

    manager.RequestDefaultAgent(AGENT_PATH)

    mainloop.run()

Don’t forget to chmod +x:

chmod +x /opt/pw-speaker

Create a systemd service as follows:

Make a file with this content in
/etc/systemd/user/speaker-agent.service

[Unit]
Description=Bluetooth speaker agent

[Service]
ExecStart=/opt/pw-speaker

[Install]
WantedBy=default.target

Make systemd know about changes, and enable this service for all users:

systemctl --global daemon-reload
systemctl --global enable speaker-agent
sed -i 's/#JustWorksRepairing.*/JustWorksRepairing = always/' /etc/bluetooth/main.conf

I rebooted, logged in, and bingo.
My phone connects to my laptop, and plays audio on the laptops speaker.
I think the sound would be routed to the headphone output when attached, I still need to confirm, this really works.

Let me know, how it goes for you :wink:

3 Likes

Looks like this is going to work as i had hoped .

The real test will be next summer season when our animators arrive and want to connect the different devices they bring with them to our sound system.

This closing season i have managed to connect using a stock of cables with different wiring standards, only failed once with a really old apple ipod and a strange connection on that, but it did not have bluetooth anyway. Ended up geting his playlist and downloading all the music again onto my linux box. But it was a artist who will not be coming back so not a worry.

Thanks for all your efforts and finding me a solution.

2 Likes

I’m really glad it works for you :slight_smile:
You’re most welcome :slight_smile:

2 Likes