Skip to content

Example setup on Raspberry Pi

wastis edited this page Sep 1, 2022 · 7 revisions

Pulseaudio Equalizer works well with Raspberry Pi 2b / 3b. Tested in combination with h264 hw-video-decoding.

Test System

Kodi 19.3 / 19.4

Raspberry Pi OS Lite, Release date: January 28th 2022 System: 32-bit Kernel version: 5.10 Debian version: 11 (bullseye)

Performance

Pulseaudio + pulseequalizer CPU consumption @ a buffer-size of 8-fragments, 15ms each, no overclocking

  • Raspberry PI 2B: ~30% on one core, 7%-8% overall
  • Raspberry PI 3B: ~20% on one core, 5%-6% overall

Install / Configure System and Packages

Get latest Raspberry Pi OS Lite

# Download "Raspberry Pi OS Lite" and write it to sd-card.

# ensure latest software
sudo apt update
sudo apt upgrade -y

sudo reboot

Install and configure kodi, pulseaudio, pulseaudio-equalizer

#install required packages
sudo apt install -y kodi pulseaudio pulseaudio-equalizer swh-plugins

#pi3 - optional, install pulseaudio bluetooth module
sudo apt install -y pulseaudio-module-bluetooth

# add user pi to the required groups 
sudo usermod -a -G input,pulse pi

#prepare kodi startup in user session
mkdir -p ~/.config/systemd/user/

#create Kodi startup script
echo -e '[Unit]\n Description=kodi startup service\n After = pulseaudio.service\n\n[Service]\n Environment = KODI_AE_SINK=PULSE\n ExecStart=/usr/lib/arm-linux-gnueabihf/kodi/kodi.bin\n TimeoutSec=0\n StandardOutput=journal\n StandardError=journal\n Restart = on-abort\n RemainAfterExit=yes\n\n[Install]\n WantedBy=default.target\n' > ~/.config/systemd/user/kodi.service

# enable pulseaudio and kodi
systemctl --user daemon-reload
systemctl --user enable pulseaudio.service
systemctl --user enable pulseaudio.socket

# start pulseaudio, ensure default configuration is created
systemctl --user start pulseaudio.service

# enable kodi service
systemctl --user enable kodi.service

#create pulseaudio user configuration
mkdir -p ~/.config/pulse
cp /etc/pulse/daemon.conf /etc/pulse/default.pa ~/.config/pulse/

# increase pulseaudio buffer size (otherwise there will be interrupted audio and high cpu load)
echo -e 'default-fragments = 8\n' >> ~/.config/pulse/daemon.conf

# optional - create static audio filter
echo -e 'load-module module-equalizer-sink sink_name=eq_1 sink_properties="device.description=EQ-1"\nload-module module-ladspa-sink sink_master=eq_1 sink_name=co_1 sink_properties="device.description=CO-1" plugin=sc4_1882 label=sc4 control=1,1.5,401,-20,20,5,15' >>  ~/.config/pulse/default.pa

# restart pulseaudio with the correct settings
systemctl --user restart pulseaudio.service

#enable user linger for the user pi. This will load the user's systemd scripts at start up
loginctl enable-linger pi

#
# Install PulseEqualizer Gui
#

# create addon directory
mkdir -p ~/.kodi/addons/script.pulseequalizer.gui

# download PulseAudioEqualizer and extract it to the addon directory
wget -O pulseequalizer.tar.gz https://github.com/wastis/PulseEqualizerGui/archive/refs/heads/main.tar.gz
tar --strip-components 1 -C ~/.kodi/addons/script.pulseequalizer.gui -xf pulseequalizer.tar.gz

# pi3 optional, install bluetooth manager
mkdir -p ~/.kodi/addons/script.bluetooth.man
wget -O bluetooth.tar.gz https://github.com/wastis/BluetoothManager/archive/refs/heads/master.tar.gz
tar --strip-components 1 -C ~/.kodi/addons/script.bluetooth.man -xf bluetooth.tar.gz

#reboot
sudo reboot

Performance Optimization

Due to some configuration in current Raspberry Pi OS Lite / Kodi, Python3-caching is not working properly with Kodi. This causes PulseAudioGui to react very slow on key presses.

In the following, there are two quick solutions to that problem.

Option 1

Change access rights to python cache

This method is less secure, on the positive site, only required libraries get compiled when needed.

#enable write access to Python system packages cache
sudo find /usr/lib/python3* -name "__pycache__" -exec chmod -R 777 {} \;

Option 2

Pre-compile all libraries with optimization level 1

This method is more secure, might need to be redone after upgrades

#precompile python3 system packages with optimization enabled
sudo python -m compileall -o 1 /usr/lib/python3*
Clone this wiki locally