2021-02-15, 13:52
Kodi with Equalizer on Ubuntu
Unfortunately dsp functionality has been dropped from Kodi a while back so the key reasons why i started to move away from the really great libreElec and to install LinuxMint 20.1 Xfce + Kodi was the lack of a working equalizer and automatic volume control on libreelec.
With the SSD's, the boot time of LinuxMint is really fast nowadays, so there is limited advantage to have a "reduced" linux compared to a full featured installation on a X86.
As I am ageing, my capability of hearing high frequencies declines, it becomes more difficult to understand what people say in movies. So an audio amplifier profile with high frequencies amplified while lowering low frequencies does really help. In addition to that, as I watch movies in night, I need a functionality that constantly adjusts the volume to keep it at the same level all the time. There is this trick in Kodi to amplify into saturation and lower the volume afterwards, however I have the impression that it reduces the audio quality. So the idea is to use the dsp functionality of the OS.
It really takes some time to search the Internet for the possible solutions and do testing, in addition there are also some problems with the packages in question, so I decided to write what I did and what worked for me.
On Ubuntu I found 3 key solution for an audio equalizer:
pulseaudio-equalizer
+ easy to install
+ stable
+ low cpu consumption compared to others
- does not provide automatic volume control functionality, so additional module would be required
- I have not found a way to switch profiles from command line, yet. This would be required to switch profiles from within Kodi via a script or similar
PulseEffects
+ easy to install
+ stable
+ provides a lot of different dsp's including automatic volume control (autogain)
- high cpu consumption (consumes about 30% on my cpu power), I think this is because it is based on gstreamer
any of the 3rd party LADSPA with PulseAudio - module-ladspa-sink
- this option is dead from beginning because for whatever reason, the module is currently missing in the Ubuntu packages. And to compile and configure pulseaudio is really a pain.
+ has lot of potential
For now, I decided for PulseEffects because of the included automatic volume control. In the future, if the issue with the missing module-ladspa-sink is sorted, I might switch to a combination of this and pulseaudio-equalizer, to reduce CPU consumption.
Install process
I use LinuxMint 20.1 Xfce as base system, Xfce because it consumes less resources.
Some useful prerequisites if you want a Kodi box.
First, on a fresh installation of my media box, I enable ssh and install vim. I like vim but you can of course also use nano or something else.
I do any further settings from my work pc, where possible, via ssh or putty.
Get the latest...
configure autologin, if forgotten in the install process, you need to replace USERID with your own
Install Kodi
Install PulseEffects from flatpak because the module "Equalizer" of PulseEffect is missing in the Ubuntu packages, why should it be different....
Autostart PulseEffects as background service
and then reboot.
After reboot, start Kodi in window mode and play a movie to produce audio output.
Start pavucontrol either from the Desktop volume control or e.g remote via ssh
Choose PulseEffects as default output device for KODI
In the "Playback" tab -> Kodi select PulseEffects(apps). It is only possible to see the Kodi line if Kodi is producing audio output- e.g. playing a movie. The same can be done for other applications, e.g. Firefox
Close window, it should keep those settings.
Configure PulseEffects, hopefully Kodi is still playing...
Start PulseEffects from Menu Start->Multimedia->PulseEffects or via ssh. It takes a bit of time until it comes up.
Enable Autogain and Equalizer and configure them as desired, close it, it will keep your settings.
Just for completeness, autostart Kodi
The issue with the volume control
One big problem with autogain is, it work against the Kodi volume control. So if I lower the volume within Kodi, autogain will automatically raise the volume as it thinks it is a quite section. So the Volume control needs to be moved out from Kodi.
Alternatively, autogain has to be disabled and the Kodi trick can be used.
I do not know whether Kodi has meanwhile the functionality to control the system volume instead of the Kodi internal volume. So one possible solution could be to write scripts that get executed when pressing the volume control. I also do not know whether this can be done easy within Kodi and I am not going into this as the luck plays for me...
I have a USB multimedia remote, similar to the Windows MCE, where nowadays, by default, the Multimedia keys are filtered by the OS and not sent to Kodi. To get the multimedia keys - except the volume control - into Kodi, I have done this.
There are still some keys missing and as I couldn't live without those, I now use inputlirc as described here , but I wrote me a little C program that forks the Volume control event back to the OS before it goes to inputlirc. I guess this is a topic for a future post or so.
Whats next
Open is still on how to switch between equalizer profiles from within Kodi, from a first check this should be possible via scripts. I might look into this if time allows.
Unfortunately dsp functionality has been dropped from Kodi a while back so the key reasons why i started to move away from the really great libreElec and to install LinuxMint 20.1 Xfce + Kodi was the lack of a working equalizer and automatic volume control on libreelec.
With the SSD's, the boot time of LinuxMint is really fast nowadays, so there is limited advantage to have a "reduced" linux compared to a full featured installation on a X86.
As I am ageing, my capability of hearing high frequencies declines, it becomes more difficult to understand what people say in movies. So an audio amplifier profile with high frequencies amplified while lowering low frequencies does really help. In addition to that, as I watch movies in night, I need a functionality that constantly adjusts the volume to keep it at the same level all the time. There is this trick in Kodi to amplify into saturation and lower the volume afterwards, however I have the impression that it reduces the audio quality. So the idea is to use the dsp functionality of the OS.
It really takes some time to search the Internet for the possible solutions and do testing, in addition there are also some problems with the packages in question, so I decided to write what I did and what worked for me.
On Ubuntu I found 3 key solution for an audio equalizer:
pulseaudio-equalizer
+ easy to install
+ stable
+ low cpu consumption compared to others
- does not provide automatic volume control functionality, so additional module would be required
- I have not found a way to switch profiles from command line, yet. This would be required to switch profiles from within Kodi via a script or similar
PulseEffects
+ easy to install
+ stable
+ provides a lot of different dsp's including automatic volume control (autogain)
- high cpu consumption (consumes about 30% on my cpu power), I think this is because it is based on gstreamer
any of the 3rd party LADSPA with PulseAudio - module-ladspa-sink
- this option is dead from beginning because for whatever reason, the module is currently missing in the Ubuntu packages. And to compile and configure pulseaudio is really a pain.
+ has lot of potential
For now, I decided for PulseEffects because of the included automatic volume control. In the future, if the issue with the missing module-ladspa-sink is sorted, I might switch to a combination of this and pulseaudio-equalizer, to reduce CPU consumption.
Install process
I use LinuxMint 20.1 Xfce as base system, Xfce because it consumes less resources.
Some useful prerequisites if you want a Kodi box.
First, on a fresh installation of my media box, I enable ssh and install vim. I like vim but you can of course also use nano or something else.
Code:
sudo apt install openssh-server vim -y
Get the latest...
Code:
sudo apt update
sudo apt upgrade
configure autologin, if forgotten in the install process, you need to replace USERID with your own
Code:
sudo vim /etc/lightdm/lightdm.conf
[Seat:*]
autologin-guest=false
autologin-user=USERID
autologin-user-timeout=0
Install Kodi
Code:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install kodi
Install PulseEffects from flatpak because the module "Equalizer" of PulseEffect is missing in the Ubuntu packages, why should it be different....
Code:
flatpak install com.github.wwmm.pulseeffects -y
Autostart PulseEffects as background service
Code:
vim ~/.config/autostart/PulseEffect.desktop
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=PulseEffect
Comment=
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=pulseeffects com.github.wwmm.pulseeffects --gapplication-service
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false
and then reboot.
After reboot, start Kodi in window mode and play a movie to produce audio output.
Start pavucontrol either from the Desktop volume control or e.g remote via ssh
Code:
export DISPLAY=:0 #in ssh if not done before
pavucontrol
Choose PulseEffects as default output device for KODI
In the "Playback" tab -> Kodi select PulseEffects(apps). It is only possible to see the Kodi line if Kodi is producing audio output- e.g. playing a movie. The same can be done for other applications, e.g. Firefox
Close window, it should keep those settings.
Configure PulseEffects, hopefully Kodi is still playing...
Start PulseEffects from Menu Start->Multimedia->PulseEffects or via ssh. It takes a bit of time until it comes up.
Code:
export DISPLAY=:0 #in ssh if not done before
flatpak run --branch=stable --arch=x86_64 --command=pulseeffects com.github.wwmm.pulseeffects
Enable Autogain and Equalizer and configure them as desired, close it, it will keep your settings.
Just for completeness, autostart Kodi
Code:
vim ~/.config/autostart/Kodi.desktop
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=Kodi
Comment=
Exec=kodi
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false
The issue with the volume control
One big problem with autogain is, it work against the Kodi volume control. So if I lower the volume within Kodi, autogain will automatically raise the volume as it thinks it is a quite section. So the Volume control needs to be moved out from Kodi.
Alternatively, autogain has to be disabled and the Kodi trick can be used.
I do not know whether Kodi has meanwhile the functionality to control the system volume instead of the Kodi internal volume. So one possible solution could be to write scripts that get executed when pressing the volume control. I also do not know whether this can be done easy within Kodi and I am not going into this as the luck plays for me...
I have a USB multimedia remote, similar to the Windows MCE, where nowadays, by default, the Multimedia keys are filtered by the OS and not sent to Kodi. To get the multimedia keys - except the volume control - into Kodi, I have done this.
There are still some keys missing and as I couldn't live without those, I now use inputlirc as described here , but I wrote me a little C program that forks the Volume control event back to the OS before it goes to inputlirc. I guess this is a topic for a future post or so.
Whats next
Open is still on how to switch between equalizer profiles from within Kodi, from a first check this should be possible via scripts. I might look into this if time allows.