A2DP agent for promiscuous/permissive audio sinc.

Overview

Promiscuous Bluetooth audio sinc

A2DP agent for promiscuous/permissive audio sinc for Linux. Once installed, a Bluetooth client, such as a smart phone, should be able to discover, pair, and subsequently play audio without any manual interaction. This is perfect for those with headless media boxes wanting to expand their connective options and saves explaining things to the kids 8)

This project assumes the use of PulseAudio and should be tested with PortAudio if required.

This project is heavily based on the Gist and comments at https://gist.github.com/mill1000/74c7473ee3b4a5b13f6325e9994ff84c#gistcomment-4032842

Caveats and roadmap

At this stage the Bluetooth device is hard coded, so please check that it matches your device. In the future such options should be set by a configuration file...

Installation

NOTE: This is very much a WIP, please comment on any additional steps required in your distro/version.

This documentation is based on my experience using Ubuntu 21.04.

Install required packages

Ensure that the required Bluetooth, Bluetooth audio, and Python 3 dependencies are installed.

sudo apt install pulseaudio-module-bluetooth bluez

Ensure Bluetooth is always discoverable

If you are using a desktop version of your OS, ensure that Bluetooth is set to visible.

Alternatively you can set the DiscoverableTimeout and PairableTimeout in /etc/bluetooth/main.conf to 0

# How long to stay in discoverable mode before going back to non-discoverable
# The value is in seconds. Default is 180, i.e. 3 minutes.
# 0 = disable timer, i.e. stay discoverable forever
DiscoverableTimeout = 0

# How long to stay in pairable mode before going back to non-discoverable
# The value is in seconds. Default is 0.
# 0 = disable timer, i.e. stay pairable forever
PairableTimeout = 0

NOTE: The above steps were not required for me.

Install the A2DP Bluetooth agent

A Bluetooth agent is a piece of software that handles pairing and authorization of Bluetooth devices. The following agent allows a client to automatically pair and accept A2DP connections from Bluetooth devices. All other Bluetooth services are rejected.

Copy the included file a2dp-agent to /usr/local/bin and make the file executable with

sudo cp -a a2dp-agent /usr/local/bin/
sudo chmod +x /usr/local/bin/a2dp-agent

Testing the agent

Before continuing, verify that the agent is functional. Bluetooth audio should be discoverable, pairable and recognised as an audio device.

  1. Manually run the agent by executing
sudo /usr/local/bin/a2dp-agent
  1. Attempt to pair and connect with using your phone or computer. You will be asked to verify a pairing key, just accept it and move on.
  2. Check on the client which profiles are available. SBC is likely your best choice quality wise. If you do not see any services then something has gone wrong 8(
  3. The agent should output the accepted and rejected Bluetooth UUIDs
Setting device to 'discoverable' and 'pairable'...
Agent registered
RequestConfirmation (/org/bluez/hci0/dev_04_B1_67_56_62_C3, 263837)
Auto confirming...
AuthorizeService (/org/bluez/hci0/dev_04_B1_67_56_62_C3, 0000110d-0000-1000-8000-00805f9b34fb)
Authorized A2DP Service

Play some audio on the client device, you should hear or see something happening on the server side 8)

Install the A2DP Bluetooth Agent as a service

To make the A2DP Bluetooth Agent run on boot copy the included file bt-agent-a2dp.service to /etc/systemd/system. Now run the following command to enable the A2DP Agent service

sudo cp -a bt-agent-a2dp.service /etc/systemd/system/
sudo systemctl enable bt-agent-a2dp.service
sudo systemctl start bt-agent-a2dp.service
systemctl status bt-agent-a2dp.service

The status should show green:

● bt-agent-a2dp.service - A2DP Bluetooth Agent
     Loaded: loaded (/etc/systemd/system/bt-agent-a2dp.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-01-19 10:26:30 NZDT; 1s ago
   Main PID: 17527 (python3)
      Tasks: 2 (limit: 18760)
     Memory: 8.9M
        CPU: 55ms
     CGroup: /system.slice/bt-agent-a2dp.service
             └─17527 /usr/bin/python3 -u /usr/local/bin/a2dp-agent

You can follow the logs of the agent with:

journalctl -fu bt-agent-a2dp.service

Higher quality audio

SBC has a bad reputation compared with other codes, but it turns out that good old SBC has a dual channel mode which can be enabled in the Developer options in recent LineageOS based Android phones. See Bluetooth SBC Dual Channel HD audio mode – LineageOS – LineageOS Android Distribution for a breakdown.

Owner
Jasper Aorangi
Jasper Aorangi
Code for "Audio-driven Talking Face Video Generation with Learning-based Personalized Head Pose"

Audio-driven Talking Face Video Generation with Learning-based Personalized Head Pose We provide PyTorch implementations for our arxiv paper "Audio-dr

Ran Yi 497 Jan 09, 2023
MUSIC-AVQA, CVPR2022 (ORAL)

Audio-Visual Question Answering (AVQA) PyTorch code accompanies our CVPR 2022 paper: Learning to Answer Questions in Dynamic Audio-Visual Scenarios (O

44 Dec 23, 2022
Open Sound Strip, Sequence or Record in Audacity

Audacity Tools For Blender Sound editing in Blender Video Sequence Editor with Audacity integrated. Send/receive the full edited sequence or single st

64 Dec 31, 2022
A collection of free MIDI chords and progressions ready to be used in your DAW, Akai MPC, or Roland MC-707/101

A collection of free MIDI chords and progressions ready to be used in your DAW, Akai MPC, or Roland MC-707/101

921 Jan 05, 2023
Make an audio file (really) long-winded

longwind Make an audio file (really) long-winded Daily repetitions are an illusion anyway.

Vincent Lostanlen 2 Sep 12, 2022
a library for audio and music analysis

aubio aubio is a library to label music and sounds. It listens to audio signals and attempts to detect events. For instance, when a drum is hit, at wh

aubio 2.9k Dec 30, 2022
A voice based calculator by using termux api in Android

termux_voice_calculator This is. A voice based calculator by using termux api in Android Instagram account 👉 👈 Requirements and installation Downloa

ʕ´•ᴥ•`ʔ╠ŞĦỮβĦa̷m̷╣ʕ´•ᴥ•`ʔ 2 Apr 29, 2022
Marsyas - Music Analysis, Retrieval and Synthesis for Audio Signals

Welcome to MARSYAS. MARSYAS is a software framework for rapid prototyping of audio applications, with flexibility and extensibility as primary concer

Marsyas Developers Group 364 Oct 31, 2022
Library for Python 3 to communicate with the Google Chromecast.

pychromecast Library for Python 3.6+ to communicate with the Google Chromecast. It currently supports: Auto discovering connected Chromecasts on the n

Home Assistant Libraries 2.4k Jan 02, 2023
Python implementation of the Short Term Objective Intelligibility measure

Python implementation of STOI Implementation of the classical and extended Short Term Objective Intelligibility measures Intelligibility measure which

Pariente Manuel 250 Dec 21, 2022
GNU Radio – the Free and Open Software Radio Ecosystem

GNU Radio is a free & open-source software development toolkit that provides signal processing blocks to implement software radios. It can be used wit

GNU Radio 4.1k Jan 06, 2023
[Singing Log] Let your program learn to sing!

[Singing Log] Let your program learn to sing! You must have thought this was changelog when you saw the English title, but it's not, it's chànggēlog. What it does is allow your program to print logs

黄巍 22 Sep 03, 2022
:speech_balloon: SpeechPy - A Library for Speech Processing and Recognition: http://speechpy.readthedocs.io/en/latest/

SpeechPy Official Project Documentation Table of Contents Documentation Which Python versions are supported Citation How to Install? Local Installatio

Amirsina Torfi 870 Dec 27, 2022
Algorithmic Multi-Instrumental MIDI Continuation Implementation

Matchmaker Algorithmic Multi-Instrumental MIDI Continuation Implementation Taming large-scale MIDI datasets with algorithms This is a WIP so please ch

Alex 2 Mar 11, 2022
This library provides common speech features for ASR including MFCCs and filterbank energies.

python_speech_features This library provides common speech features for ASR including MFCCs and filterbank energies. If you are not sure what MFCCs ar

James Lyons 2.2k Jan 04, 2023
A small project where I identify notes and key harmonies in a piece of music and use them further to recreate and generate the same piece of music through Python

A small project where I identify notes and key harmonies in a piece of music and use them further to recreate and generate the same piece of music through Python

5 Oct 07, 2022
A tool for retrieving audio in the past

Rewinder A tool for retrieving audio in the past. Ever felt like, I need to remember that discussion which happened 10 min back. Now you can! Rewind a

Bharat 1 Jan 24, 2022
Audio2midi - Automatic Audio-to-symbolic Arrangement

Automatic Audio-to-symbolic Arrangement This is the repository of the project "A

Ziyu Wang 24 Dec 05, 2022
This Bot can extract audios and subtitles from video files

Send any valid video file and the bot shows you available streams in it that can be extracted!!

TroJanzHEX 56 Nov 22, 2022
PianoPlayer - Automatic fingering generator for piano scores

PianoPlayer - Automatic fingering generator for piano scores

Marco Musy 571 Jan 02, 2023