• 1
  • 2(current)
  • 3
  • 4
  • 5
  • 7
Linux HOWTO Kodi with Equalizer on LinuxMint 20.1
#16
(2021-09-12, 09:40)heysoundude Wrote: What about on the Pi4? 4GB of RAM should help…
This is a Feature I would LOVE to be able to use

 Ok, I did a closer look to it, still using Pi3, the performance actually is not the problem, it consumes about 25% of one core, so 6% overall.

The problem currently is that Kodi somehow is set to ALSA output only, so far I did not manage to output the sound directly to pulseaudio (without ALSA in-between).

There is this ALSA plugin pulseaudio, which is currently use for BT devices. I did hijack this to route the audio from Kodi via ALSA to the pulse equalizer and this works perfect with the annoying drawback, that the audio latency naturally caused by the equalizer is not reported back to Kodi and thus Audio and Video are out of sync of about 350ms.

Currently I have no Idea how to fix this other than changing Kodi source, a route I currently don't want to go.

The changes to the Kodi PulseEqualizer GUI Addon are minor and only required if ALSA would remain the main source for the equalizer.

Any ideas are welcome, I did use latests Raspberry Pi OS Lite version for testing with default Kodi 18.7.

EDIT: OK, I go this sorted. Update on Addon package will follow.
Reply
#17
Hi all,

I have published a new release v1.0.3 on git, which will also run on raspberry PI 3 OS Lite and headless systems.

Please see README.md for the specific startup on raspberry and headless systems.

PulseEqualizerGui v.1.0.3
Reply
#18
And an other release with major changes in the software design and many new features and improvements. 
  • added latency-offset slider
  • possibility to switch equalizer on/off
  • change output selection method
  • added system volume control
  • automatic module loading, simplified pulseaudio configuration
  • save settings per selected device (volume, profile and latency)
  • automatic bluetooth device switching
  • skip filter if no playback (no latency on GUI sounds)

PulseEqualizerGui v2.0.0
Reply
#19
Hi,
thank you for providing this plugin!
I have installed the plugin on my Jetson Nano running Ubuntu 18.04 and Kodi 19.3 and I am unable to get it running.

Pulseaudio-equalizer is installed, and the plugin seems to load normally. I am able to select the output and the latency, but nothing shows when I click on Equalizer, or the profile related settings.

The kodi.log shows:
Code:

2021-11-30 17:50:16.731 T:8005     INFO <general>: equalizer: start addon
2021-11-30 17:50:16.731 T:8005     INFO <general>: equalizer: addon has been selected and is first instance
2021-11-30 17:50:24.848 T:8015    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/pulseinterface/pacentral.py: 90
2021-11-30 17:50:24.848 T:8015    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/pulseinterface/eqcontrol.py: 60
2021-11-30 17:50:24.848 T:8015    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/pulseinterface/eqcontrol.py: 85
2021-11-30 17:50:24.848 T:8015    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/pulseinterface/eqcontrol.py: 46
2021-11-30 17:50:24.849 T:8005    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/addon.py: 48
2021-11-30 17:50:24.849 T:8005    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/menus.py: 42
2021-11-30 17:50:24.849 T:8005    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/menus.py: 52
2021-11-30 17:50:24.849 T:8005    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/menus.py: 206
2021-11-30 17:50:24.849 T:8005    ERROR <general>: eq: in: /home/michael/.kodi/addons/script.pulseequalizer.gui/resources/lib/helper/socketcom.py: 97
2021-11-30 17:50:24.849 T:8005     INFO <general>: CPythonInvoker(18, /home/michael/.kodi/addons/script.pulseequalizer.gui/addon.py): script successfully run


The Github-page lists only 'pulseaudio-equalizer' as a requirement, this forum shows a lot of additional requirements - but these might be related to older plugin-versions only.

Maybe you can give me some hints on what could be missing or wrong.

Thank you
Reply
#20
Hi @MicTie 
I have not tested it on ubuntu 18 however this looks like an user session problem, so dbus is not running or not accessible from Kodi. This indicates an startup script problem.

Is this a headless system, so without a desktop?

One test could be: - exit Kodi(not shutdown) - login to the machine via ssh as user and check if pulse audio is running
 
Code:
ps -ef | grep pulseaudio

user         457     427  1 14:18 ?        00:00:01 /usr/bin/pulseaudio --verbose --daemonize=no
user         591     586  0 14:20 pts/0    00:00:00 grep pulseaudio

if you have the same output, then start Kodi from here
 
Code:
kodi &

and then check if it is working now.

2. In Kodi, enable debug logging (Kodi- settings -> system -> expert modus -> logging -> enable debug logging
try to run equalizer

copy .kodi/temp/kodi.log to https://paste.kodi.tv/ and provide me with the link, so I can check whether this is an addon bug.
Reply
#21
Hi @wastis ,
this was fast - thanks!

My system is a desktop, using my TV as display, although most of the time I connect headless via SSH.

'pulsaudio' is started, but not 'demonized'

Code:

michael@michael-nano:~/.kodi/temp$ ps -ef | grep pulseaudio
michael   6629     1  1 17:47 ?        00:03:01 /usr/bin/pulseaudio --start --log-target=syslog
michael  14183  8173  0 21:40 pts/0    00:00:00 grep --color=auto pulseaudio

Also dbus is installed and running:

Code:

michael@michael-nano:~/.kodi/temp$ ps -ef | grep dbus
message+  3941     1  0 17:47 ?        00:00:06 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
michael   6114  6010  0 17:47 ?        00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
michael   6458  6453  0 17:47 ?        00:00:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
michael  21103  8173  0 22:06 pts/0    00:00:00 grep --color=auto dbus

Here the link to my kodi.log
Reply
#22
Hi @MicTie 

yes, it is a session / pulseaudio startup problem, indicated here.

 
Code:
2021-11-30 21:47:06.358 T:20857   ERROR <general>: eq: PulseDBusError: ('org.freedesktop.DBus.Error.ServiceUnknown\nThe name org.PulseAudio1 was not provided by any .service files\ndetail: python3 on connect',)

So pulseaudio does not publish the service to the user who did launch Kodi.

who is the kodi user, so the user who fires kodi up, is it also michael?
 
Code:
ps -ef | grep kodi
user         613     608  8 14:23 ?        00:04:49 /usr/lib/x86_64-linux-gnu/kodi/kodi.bin

have you been able to start kodi from a ssh session?
Reply
#23
Hi @MicTie

I thought about this again. As a work around, you could try to connect directly to the dbus socket, if it exists. To do so do the following.

figure out your userid
 
Code:
cat /etc/passwd | grep user

user:x:1000:1000:user,,,:/home/user:/bin/bash

the first 1000 is the userid.

check if socket exists
 
Code:
ls -l /run/user/1000/pulse

srwxrwxrwx 1 user user 0 30. Nov 17:54 dbus-socket
srw-rw-rw- 1 user user 0 30. Nov 17:54 native
-rw------- 1 user user 4 30. Nov 17:54 pid
 
I have the dbus-socket when dbus module is loaded (Kodi is running), if you don't have it, then there is definitely a problem with pulseaudio startup

set the environment variable in your startup script
 
Code:
PULSE_DBUS_SERVER=unix:path=/run/user/1000/pulse/dbus-socket
my startup script looks like this, then
cat /etc/systemd/system/kodi.service
 
Code:
[Unit]
 Description=kodi startup service

[Service]
 Type=simple
 ExecStart=su -c 'PULSE_DBUS_SERVER=unix:path=/run/user/1000/pulse/dbus-socket /usr/bin/kodi' user 2>&1 &
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target
reboot and with a bit of luck this works.

Further you could either enable logging for pulseaudio -vv in your startup script or stop the pulseaudio service and start pulseaudio in a ssh session and look at the beginning of the log.
 
Code:
systemctl --user stop pulseaudio.service
systemctl --user stop pulseaudio.socket

pulseaudio -v

I: [pulseaudio] main.c: This is PulseAudio 14.2
I: [pulseaudio] main.c: Page size is 4096 bytes
I: [pulseaudio] main.c: Machine ID is 0cd85806162b4ffcae2d3779dd18c549.
I: [pulseaudio] main.c: Session ID is 2.
I: [pulseaudio] main.c: Using runtime directory /run/user/1000/pulse.
I: [pulseaudio] main.c: Using state directory /home/user/.config/pulse.
I: [pulseaudio] main.c: Using modules directory /usr/lib/pulse-14.2/modules.
I: [pulseaudio] main.c: Running in system mode: no

Finally I did set up a headless server on ubuntu 18.04.6 LTS with Kodi and equalizer, so I can confirm that it is working on Ubuntu 18.04.6 LTS without any problems.
Reply
#24
Hi @wastis,
thanks for your help.
I got it running by adding 'Environment = PULSE_DBUS_SERVER=unix:path=/run/user/1000/pulse/dbus-socket' to my kodi_start.service
Code:

[Unit]
Description = kodi-x11 start
Requires = dbus.service
After = systemd-user-sessions.service sound.target network-online.target

[Service]
User = michael
Group = michael
Type = simple
Environment = DISPLAY=:0
Environment = PULSE_DBUS_SERVER=unix:path=/run/user/1000/pulse/dbus-socket
ExecStart =  /home/michael/xbmc/build/kodi-x11
Restart = on-abort
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy = multi-user.target

I still have a couple of questions:
  which output-device do I have to select in System->Audio? I see among others HDMI/PULSAUDiO (which I usually use) but also EQUALIZER?
  which output device do I have to select in the Equalizer-Plugin? is it HDMI/PULSAUDIO?
  what is the best way to use a specific (default) profile automatically?
  am I right to say that the plugin a NOT working when I use PASSTHROUGH? (I am using it most of the times to enjoy DOLBY/DTS-sound ...

Thank you!
Reply
#25
I am glad it worked for you.

Yes, pulseaudio equalizer should not touch the audio stream if you use pass through - the purpose of pass through. The equalizer should not be in the output chain in this case.

You have a number of options to configure your output. So in principle,  you could select any pulse audio device as output device and switch pulseaudio equalizer on/off, dependent if you want to use pass through or not. You could also select "Equalizer" as output, which then routes it's output to default pulse audio device. In this case, you do not have pass through.

Another option could be to have another persistent equalizer module loaded with your preferred settings (channels, rate, output device) and select between this persistent equalizer and direct output, dependent on pass through. More details on how to do this is in the advanced configuration in github.

Automatic switch depended on pass through is currently not implemented. I need to investigate on whether this can be done and implemented. However my focus and priority is currently on digital room correction per channel.

Enjoy
Reply
#26
Thank you so much for your fast and efficient help!
Reply
#27
@MicTie 

Ok, I think I may have found the root cause of the problem testing your startup script. It seems that Kodi and with this the addon is launched before the filesystem /run/user/1000/pulse is set-up properly. So in your case, the pulseaudio dbus service is not available by the time Kodi is launched. 

I avoid this by using "su" in my startup. Maybe there is an optimization of the "After" targets possible.

@all,  a recommendation on an optimized startup script would be appreciated.
Reply
#28
@wastis 
my kodi startup required fiddling around for quite some time to start KODI via YATSE from my phone ...

Currently I am happy that it's working with the equalizer

Thanks!
Reply
#29
V2.1.0  of  PulseEqualizer is now finished.
This release includes Digital Room Correction, absolute freedom in selection of filter frequencies and some improvements in the GUI colors (match better to different skins).

To enable an independent configuration of the filter profiles from the room correction, I had to move the storage location away from the equalizer into the addon's settings directory. So the defined profiles of the older releases are not available anymore when upgrading.  

The learning of this thread have now been build into PulseEqualizer to make things more easy for user and to reduce frustration in set-up. If a problem occurs it is most likely new.

For startup on debian and raspi headless systems, I now recommend user-linger as described in the git. That works very well.
On Ubuntu, I did test the VAAPI set-up as described here in the form, also with success.

Finally, enjoy
Reply
#30
V2.1.1 of PulseEqualizerGUI is very stable, runs smooth on various systems including Kodi 19.3@raspberry 3B and I haven't found any issues so far.

So time for some thoughts on the quality of the pulseaudio equalizer compared to other equalizers available on Linux. I did have a closer look in its and other equalizers source code and came to the following conclusion.  

Upfront, I think pulseaudio is currently the best equalizer available on Linux, if it comes to consumer audio streaming.  The equalizer is designed around audio quality on the cost of cpu resources required and latency introduced.  Pulseaudio equalizer is a fast convolution equalizer, it runs very stable, in two years I had not a single crash caused by this equalizer.
With it's FFT size of 65536 @ 44100 or 48000 sample rate, it has a frequency resolution of 0,67 Hz, so it does very well on low frequencies which is a major concern for FFT based audio filters. Like any FIR filter, it keeps the phases and does not amplify intermediate frequencies (what IIR or bi-quad filter cascades would do). Due to it's high frequency resolution (it has 32768 bands), it is optimal for digital room correction and also enables some special use cases, for example the treatment for special forms of tinnitus, as it is possible to filter one or more frequencies with very narrow bands (Kodi's PulseEqualizerGUI can be configured for this).

Unfortunately, all this come with some compromises.

With it's hard coded sliding window size of 15999 samples, it introduces a latency of 363ms@44100 and 333ms@48000. This is not reported back correctly to applications like Kodi, which causes a sync problem of the audio and video stream. As a work around, PulseEqualizerGUI does sets the port latency of the output sink to 350ms if the equalizer is in the playback stream, so Audio and Video are in sync again. 

With its high cpu usage compared to other equalizers, it may introduce some auditable artifacts on systems with low cpu power. Nowadays however, even the raspberry PI3B has already more than sufficient power to run the equalizer smoothly with two channels and KODI 19.3 decoding x264 (thanks to the kodi developers).

How does pulseaudio equalizer compare to other equalizers.

Other equalizers are often designed around cpu performance and low latency rather than quality. Outside the streaming world (gaming, live music, professional music mastering), latency is quite an important topic. 

Examples are the EQ10 used by ALSA equalizer and mbeq_1197 used by this project for Linux desktop, of course there are also others.
 
EQ10 is a 10 band bi-quad, with the typical disadvantages of IIR filter like phase shifting and potential intermediate frequency amplification. Though it is a very good equalizer in live music environments or where CPU is a concern, it is not so ideal for digital room correction due to it's limitation to 10 Bands and frequency shifts. In my tests, it also had some ugly noise when starting playback with Kodi using this equalizer.

mbeq_1197 is a FFT equalizer with a FFT window size of 1024 samples. This gives a frequency resolution of 43Hz@44100 which destroys the signal for low frequencies. That means it can process 43Hz, 86Hz, 129Hz,... all frequencies in between those frequencies are rounded to those frequencies when this equalizer is used. I personally can clearly hear the difference of 43 and 86 Hz. On the positive side, it has a latency of only 23ms which might be useful for low latency use cases if audio quality is not so much a concern.

What does the future bring.

With pipewire around the corner, this is a very valid question. Though pipewire claims to be an adequate replacement for pulseaudio, currently it does not come with an equalizer and there a no plans to implement one. As a replacement it suggest the LADSPA module with an equalizer on top (e.q. EQ10 or mbeq_1197).

LADSPA is quite old and has some shortcomings in it's interface, that would make equalizer implementations like the pulseaudio one difficult. 
LV2 (the LADSPA successor) is currently not available on pipewire but some how in the plans. It still needs someone to implement a fast convolution equalizer based on LV2, or is there already one?
Reply
  • 1
  • 2(current)
  • 3
  • 4
  • 5
  • 7

Logout Mark Read Team Forum Stats Members Help
HOWTO Kodi with Equalizer on LinuxMint 20.10