All Projects → Arkq → Bluez Alsa

Arkq / Bluez Alsa

Licence: mit
Bluetooth Audio ALSA Backend

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Bluez Alsa

Hifiberry Os
Linux distribution optimized for audio playback
Stars: ✭ 487 (-14.26%)
Mutual labels:  audio, alsa, bluetooth
Rpi Audio Receiver
Raspberry Pi Audio Receiver with Bluetooth A2DP, AirPlay, UPnP and Spotify Connect
Stars: ✭ 650 (+14.44%)
Mutual labels:  audio, alsa, bluetooth
Balena Sound
Build a single or multi-room streamer for an existing audio device using a Raspberry Pi! Supports Bluetooth, Airplay and Spotify Connect
Stars: ✭ 1,306 (+129.93%)
Mutual labels:  audio, bluetooth
Strawberry
🍓 Strawberry Music Player
Stars: ✭ 972 (+71.13%)
Mutual labels:  audio, alsa
Pulseaudio Modules Bt
[Deprecated, see https://github.com/EHfive/pulseaudio-modules-bt/issues/154] Adds Sony LDAC, aptX, aptX HD, AAC codecs (A2DP Audio) support to PulseAudio on Linux
Stars: ✭ 1,664 (+192.96%)
Mutual labels:  audio, bluetooth
Malgo
Mini audio library
Stars: ✭ 138 (-75.7%)
Mutual labels:  audio, alsa
Mkchromecast
Cast macOS and Linux Audio/Video to your Google Cast and Sonos Devices
Stars: ✭ 1,837 (+223.42%)
Mutual labels:  audio, alsa
Multi Room Audio Centralized Audio For Home
🎵 This Github Repository provides details on setting up a centralized audio system for your home using nothing but Raspberry Pi's and Old Speakers.
Stars: ✭ 189 (-66.73%)
Mutual labels:  audio, bluetooth
Ble examples
Additional examples to compliment TI's Bluetooth Low Energy Stack offerings.
Stars: ✭ 289 (-49.12%)
Mutual labels:  audio, bluetooth
Swift Video Generator
Stars: ✭ 517 (-8.98%)
Mutual labels:  audio
Ffsubsync
Automagically synchronize subtitles with video.
Stars: ✭ 5,167 (+809.68%)
Mutual labels:  audio
Python Sounddevice
🔉 Play and Record Sound with Python 🐍
Stars: ✭ 512 (-9.86%)
Mutual labels:  audio
Freac
The fre:ac audio converter project
Stars: ✭ 518 (-8.8%)
Mutual labels:  audio
Blackhole
BlackHole is a modern macOS virtual audio driver that allows applications to pass audio to other applications with zero additional latency.
Stars: ✭ 6,834 (+1103.17%)
Mutual labels:  audio
Whipper
Python CD-DA ripper preferring accuracy over speed
Stars: ✭ 517 (-8.98%)
Mutual labels:  audio
Soundfingerprinting
Open source audio fingerprinting in .NET. An efficient algorithm for acoustic fingerprinting written purely in C#.
Stars: ✭ 554 (-2.46%)
Mutual labels:  audio
Rtmppublisher
Rtmp client on Android. Live Video Streaming.
Stars: ✭ 515 (-9.33%)
Mutual labels:  audio
Friture
Real-time audio visualizations (spectrum, spectrogram, etc.)
Stars: ✭ 509 (-10.39%)
Mutual labels:  audio
Hysteriaplayer
Objective-C audio player, sitting on top of AVPlayer
Stars: ✭ 568 (+0%)
Mutual labels:  audio
Zynaddsubfx
ZynAddSubFX open source synthesizer
Stars: ✭ 554 (-2.46%)
Mutual labels:  alsa

Bluetooth Audio ALSA Backend Build Status

This project is a rebirth of a direct integration between BlueZ and ALSA. Since BlueZ >= 5, the build-in integration has been removed in favor of 3rd party audio applications. From now on, BlueZ acts as a middleware between an audio application, which implements Bluetooth audio profile, and a Bluetooth audio device.

The current status quo is, that in order to stream audio from/to a Bluetooth device, one has to install PulseAudio, or use BlueZ < 5. However, BlueZ version 4 is considered to be deprecated, so the only reasonable way to achieve this goal is to install PulseAudio.

With this application (later named as BlueALSA), one can achieve the same goal as with PulseAudio, but with less dependencies and more bare-metal-like. BlueALSA registers all known Bluetooth audio profiles in BlueZ, so in theory every Bluetooth device (with audio capabilities) can be connected. In order to access the audio stream, one has to connect to the ALSA PCM device called bluealsa. Please note that this PCM device is based on the ALSA software PCM I/O plugin - it will not be available in the ALSA Kernel proc interface.

Installation

autoreconf --install
mkdir build && cd build
../configure --enable-aac --enable-ofono --enable-debug

or if you intend to stream audio from a Linux distribution using PulseAudio < 13.0 (see this issue)

../configure --enable-aac --enable-ofono --enable-debug --disable-payloadcheck

then

make && make install

Dependencies:

  • alsa-lib
  • bluez >= 5.0
  • glib with GIO support
  • sbc
  • mp3lame (when MP3 support is enabled with --enable-mp3lame)
  • mpg123 (when MPEG decoding support is enabled with --enable-mpg123)
  • fdk-aac (when AAC support is enabled with --enable-aac)
  • openaptx (when apt-X support is enabled with --enable-aptx and/or --enable-aptx-hd)
  • libopenaptx (when apt-X support is enabled and --with-libopenaptx is used)
  • libldac (when LDAC support is enabled with --enable-ldac)
  • docutils (when man pages build is enabled with --enable-manpages)

Dependencies for client applications (e.g. bluealsa-aplay):

Dependencies for bluealsa-rfcomm (when --enable-rfcomm is specified during configuration):

Dependencies for hcitop (when --enable-hcitop is specified during configuration):

For a comprehensive installation guide, please look at the Installation from source bluez-alsa wiki page. If you've found something missing or incorrect, fill free to make a wiki contribution. Alternatively, if you are using Debian-based distribution, take a look at the .travis.yml file, it might give you a hint about required packages.

Configuration & Usage

The main component of BlueALSA is a program called bluealsa. By default, this program shall be run as a root during system startup. It will register org.bluealsa service in the D-Bus system bus, which can be used for accessing configured audio devices. In general, BlueALSA acts as a proxy between BlueZ and ALSA.

For details of command-line options to bluealsa, consult the bluealsa man page.

In order to stream audio to the e.g. Bluetooth headset, firstly one has to connect the device. The most straightforward method is to use BlueZ CLI utility called bluetoothctl. When the device is connected one can use the bluealsa virtual PCM device as follows:

aplay -D bluealsa:DEV=XX:XX:XX:XX:XX:XX,PROFILE=a2dp Bourree_in_E_minor.wav

Setup parameters of the bluealsa PCM device can be set in the local .asoundrc configuration file like this:

cat ~/.asoundrc
defaults.bluealsa.service "org.bluealsa"
defaults.bluealsa.device "XX:XX:XX:XX:XX:XX"
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000

BlueALSA also allows to capture audio from the connected Bluetooth device. To do so, one has to use the capture PCM device, e.g.:

arecord -D bluealsa capture.wav

Using this feature, it is possible to create Bluetooth-powered speaker. It is required to forward audio signal from the BlueALSA capture PCM to some other playback PCM (e.g. build-id audio card). In order to simplify this task, there is a program called bluealsa-aplay, which acts as a simple BlueALSA player. Connect your Bluetooth device (e.g. smartphone) and do as follows:

bluealsa-aplay XX:XX:XX:XX:XX:XX

For details of command-line options to bluealsa-aplay, consult the bluealsa-aplay man page.

In addition to A2DP profile, used for high quality audio, BlueALSA also allows to use phone audio connection via SCO link. One can use either build-in HSP/HFP support, which implements only audio related part of the specification, or use oFono service as a back-end. In order to open SCO audio connection one shall switch to sco profile like follows:

aplay -D bluealsa:DEV=XX:XX:XX:XX:XX:XX,PROFILE=sco Bourree_in_E_minor.wav

The list of available BlueALSA PCMs (provided by connected Bluetooth devices with audio capabilities) can be obtained directly from BlueALSA D-Bus API or using bluealsa-aplay as a convenient wrapper as follows:

bluealsa-aplay -L

In order to control input or output audio level, one can use provided bluealsa control plugin. This plugin allows adjusting the volume of the audio stream or simply mute/unmute it, e.g.:

amixer -D bluealsa sset '<control name>' 70%

where the control name is the name of a connected Bluetooth device with a control element suffix, e.g.:

amixer -D bluealsa sset 'Jabra MOVE v2.3.0 - A2DP' 50%

For more advanced ALSA configuration, consult the asoundrc on-line documentation provided by the AlsaProject wiki page.

Troubleshooting

  1. Using BlueALSA alongside with PulseAudio.

    Due to BlueZ limitations, it seems, that it is not possible to use BlueALSA and PulseAudio to handle Bluetooth audio together. BlueZ can not handle more than one application which registers audio profile in the Bluetooth stack. However, it is possible to run BlueALSA and PulseAudio alongside, but Bluetooth support has to be disabled in the PulseAudio. Any Bluetooth related module has to be unloaded - e.g. bluetooth-discover, bluez5-discover.

  2. ALSA thread-safe API (alsa-lib >= 1.1.2, <= 1.1.3).

    Starting from ALSA library 1.1.2, it is possible to enable thread-safe API functions. It is a noble change, but the implementation leaves a lot to be desired. This "minor" change does not affect hardware audio devices (because for hardware devices, this change is disabled), but it affects A LOT all software plug-ins. Random deadlocks are inevitable. My personal advice is to disable it during alsa-lib configuration step (./configure --disable-thread-safety), or if it is not possible (installation from a package repository), disable it via an environmental variable, as follows: export LIBASOUND_THREAD_SAFE=0.

  3. Couldn't acquire D-Bus name: org.bluealsa

    It is not possible to run more than one instance of the BlueALSA server per D-Bus interface. If one tries to run second instance, it will fail with the "Couldn't acquire D-Bus name: org.bluealsa" error message. This message might also appear when D-Bus policy does not allow acquiring "org.bluealsa" name for a particular user - by default only root is allowed to start BlueALSA server.

  4. Couldn't get BlueALSA PCM: PCM not found

    In contrast to standard ALSA sound cards, BlueALSA does not expose all PCMs right away. In the first place it is required to connect remote Bluetooth device with desired Bluetooth profile - run bluealsa --help for the list of available profiles. For querying currently connected audio profiles (and connected devices), run bluealsa-aplay --list-devices. The common misconception is an attempt to use A2DP playback device as a capture one in case where A2DP is not listed in the "List of CAPTURE Bluetooth Devices" section.

    Additionally, the cause of the "PCM not found" error might be an incorrect ALSA PCM name. Run bluealsa-aplay --list-pcms for the list of currently available ALSA PCM names - it might give you a hint what is wrong with your .asoundrc entry. Also, take a look at the "Using the bluealsa ALSA pcm plugin" bluez-alsa wiki page.

Resources

  1. Bluetooth Adopted Specifications
  2. Bluetooth Design Guidelines
  3. RTP Payload Format for MPEG-4
  4. Coding of MPEG-4 Audio
  5. ALSA project library reference
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].