Skip to content

Example setup on Raspberry Pi

wastis edited this page May 26, 2023 · 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: September 6th 2022 System: 32-bit Kernel version: 5.15 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.

  • enable ssh by writing an empty file named ssh to boot partition of the SD card

  • Boot it that it expands filesystem, follow the menu to create user

Prepare System

# 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 $USER to the required groups 
sudo usermod -a -G input,pulse $USER

#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 $USER

#
# Install PulseEqualizer Gui and Bluetooth Manager
#

# download linux addon repository and extract it to the addon directory
wget https://raw.github.com/wastis/LinuxAddonRepo/master/repository.linuxaddons-1.0.1.zip
unzip -d ~/.kodi/addons repository.linuxaddons-1.0.1.zip

#reboot
sudo reboot

#within kodi -> install from repository -> Linux Addon Repository -> Program add-ons -> Pulse Equalizer

#within kodi -> install from repository -> Linux Addon Repository -> Program add-ons -> Bluetooth Manager

Performance Optimization

Due to some code in Kodi, Python3-caching is not working properly with Kodi. This causes PulseAudioGui and other addons to react very slow on key presses. For more info see here.

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*