Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Moode 8: Add bluetooth codec support for AAC, aptX & aptX-HD to bluez-alsa package
#30
(05-16-2023, 09:16 PM)jenzd Wrote: Moode 8 already has built-in support for the bluetooth codecs SBC (receive & playback) and LDAC (playback only, but inactive by default) which is provided by the bluez-alsa package. At the time of writing Moode version 8.3.2 includes bluez-alsa in version 4.0.0.

The following guide shows how to additionally include support for the bluetooth codecs AAC, aptX and aptX-HD (each for receive & playback) by building a modified version of the included bluez-alsa package. Note that this guide is based on section 5 "Build packages" of Moode's "Master development guide". It follows a slightly different route than the previous guide by scblock which showed how to build & install everything directly from the source code without building a package (see https://moodeaudio.org/forum/showthread.php?tid=3683). In the current approach, the modification is finally installed as a normal package instead. There should be no side effects on future in-place updates of Moode other than that the modified package might be upgraded to a newer (unmodified) bluez-alsa version.

The build process can be performed directly in Moode using ssh access, e.g. on a fresh installation.


1) After logging into Moode via ssh, we start with installing some additional building tools and dependencies:

Code:
# update the package repository
sudo apt update

# install build tools for deb packages
sudo apt install build-essential fakeroot devscripts

# install missing build dependencies for the bluez-alsa package
sudo apt install dh-exec libasound2-dev libbluetooth-dev libsbc-dev pandoc python3-docutils

# install codec libraries and development files for LDAC, AAC and aptx
sudo apt install libldacbt-abr2 libldacbt-abr-dev libldacbt-enc2 libldacbt-enc-dev libfdk-aac2 libfdk-aac-dev libopenaptx0 libopenaptx-dev


2) Then we download Moode's source package for bluez-alsa to the current directory and change into its configuration directory:

Code:
# download bluez-alsa source package
apt source bluez-alsa

# change to its configuration directory
cd bluez-alsa-4.0.0/debian


3) Two files need to be modified here (e.g. using "nano <filename>"):
  • File "rules":

    Add flags for the additional codecs in the CONFIGURE_FLAGS section, so that it reads

Code:
CONFIGURE_FLAGS := \
       --enable-ldac \
       --enable-ofono \
       --enable-manpages \
       --enable-debug \
       --enable-cli \
       --enable-aac \
       --enable-aptx \
       --enable-aptx-hd \
       --with-libopenaptx


instead of the default parameters


Code:
CONFIGURE_FLAGS := \
       --enable-ldac \
       --enable-ofono \
       --enable-manpages \
       --enable-debug \
       --enable-cli

  • File "changelog":

    Edit the version of the package in the first line of the file to distinguish it from the original version provided by moode, e.g. by adding "+codecs" at the end of the version string, resulting in "4.0.0-2moode1+codecs" instead of the default "4.0.0-2moode1".

3) Build the modified package:

Code:
# change back to the directory bluez-alsa-4.0.0/
cd ..

# build the modified package
dpkg-buildpackage -us -uc

# change back to the parent directory
cd ..

If the build process was successful, the parent directory of "bluez-alsa-4.0.0" should contain a set of modified deb packages.


4) Install the modified deb packages to replace the preinstalled versions of "bluez-alsa-utils" and "libasound2-plugin-bluez":

Code:
# install modified packages from local source
sudo apt install ./bluez-alsa-utils_4.0.0-2moode1+codecs_arm64.deb ./libasound2-plugin-bluez_4.0.0-2moode1+codecs_arm64.deb


5) Activate aptX, aptX-HD and LDAC in the config file of the bluealsa service (AAC is already activated by default):

Code:
# Edit the config file of the bluealsa service
sudo nano /etc/systemd/system/bluealsa.service

to change the line

Code:
ExecStart=/usr/bin/bluealsa -p a2dp-source -p a2dp-sink

to

Code:
ExecStart=/usr/bin/bluealsa -p a2dp-source -p a2dp-sink -c aptx -c aptx-hd -c ldac

Note: The config file /etc/systemd/system/bluealsa.service belongs to the package moode-player, so it will be overwritten with each in-place update of Moode, This means that step 5 unfortunately needs to be repeated after each Moode update.


6) Finally reboot:

Code:
sudo reboot


The additional codecs should now be used automatically when a supported bluetooth device is connected.


Final note: In case you want to remove the modification again, just undo the changes to the file /etc/systemd/system/bluealsa.service and reinstall the unmodified versions provided by Moode from the package repository (currently version 4.0.0-2moode1).

Code:
sudo apt install bluez-alsa-utils=4.0.0-2moode1 libasound2-plugin-bluez=4.0.0-2moode1

Starting with Moode 8.3.3, aptX and aptX-HD support is now officially built into the included bluez-alsa package 4.1.0-2moode2 (and activated by default). There is no need to follow the above guide for these codecs any longer.

Support for AAC (e.g. commonly used by Apple devices) is still missing, however, probably because the underlying library libfdk-aac2 is part of the non-free section of Debian's package repository. So the guide still (but only) makes sense in case you want to build a bluez-alsa package with additional AAC support.

This post conserves the original guide for Moode 8.3.2. I will update the first page to reflect the new situation for Moode 8.3.3.

Regards
Jens
Reply


Messages In This Thread
RE: Moode 8: Add bluetooth codec support for AAC, aptX & aptX-HD to bluez-alsa package - by jenzd - 06-19-2023, 10:38 PM

Forum Jump: