Peppy player

Well, equal plugin works differently than e.g. softvol.

Softvol adds its control to controls list of the underlying hw:X card:

alsa-lib/pcm_softvol.c at master * alsa-project/alsa-lib * GitHub

alsa-lib/pcm_softvol.c at master * alsa-project/alsa-lib * GitHub

alsa-lib/pcm_softvol.c at master * alsa-project/alsa-lib * GitHub

That means upon opening the PCM device which has the softvol plugin in its configured chain, the softvol CTL element is added to the list of hw:X device controls, permanently.

However the equal plugin does not do that, it uses the ctl API for creating its control elements. If the CTL config for the "equal" PCM device defines a different CTL config (e.g. by using the control of the actual card by configuring ctl.equal = type hw, card X), the controls of the equal plugin are not used at all.

Actually configuring ctl.equal type=equal is supported, the config is used for fine-tuning the equalizer params alsaequal/README at master * raedwulf/alsaequal * GitHub .

Source code is the best documentation :)
 
MrGlasspole,
when player starts it logs the following messages:
Code:
[2020-07-09 17:49:59,571] {webserver.py:106} DEBUG - Web Server Started
[2020-07-09 17:50:00,057] {peppy.py:313} DEBUG - Audio Server Started
Did you see that? If not, please make sure that you set file.logging = True
and specified a valid file name in the property log.filename. Here is the example:
Code:
[logging]
file.logging = True
log.filename = /home/pi/Peppy/peppy.log
console.logging = False
enable.stdout = True
show.mouse.events = False


The player mostly logs messages in case of errors. When player starts it overrides the previous log file.


Best regards
 
Code:
pcm.equal {
  type equal
  slave.pcm "hw:1"
}

Code:
pavel@x220 ~ $ amixer -D equal contents
numid=1,iface=MIXER,name='00. 31 Hz Playback Volume'
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=2,iface=MIXER,name='01. 63 Hz Playback Volume',device=1
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=3,iface=MIXER,name='02. 125 Hz Playback Volume',device=2
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=4,iface=MIXER,name='03. 250 Hz Playback Volume',device=3
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=5,iface=MIXER,name='04. 500 Hz Playback Volume',device=4
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=6,iface=MIXER,name='05. 1 kHz Playback Volume',device=5
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=7,iface=MIXER,name='06. 2 kHz Playback Volume',device=6
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=8,iface=MIXER,name='07. 4 kHz Playback Volume',device=7
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=9,iface=MIXER,name='08. 8 kHz Playback Volume',device=8
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66
numid=10,iface=MIXER,name='09. 16 kHz Playback Volume',device=9
  ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1
  : values=66,66

Code:
pavel@x220 ~ $ amixer -c 1
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 74
  Mono: Playback 74 [100%] [0.00dB] [off]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 74
  Mono:
  Front Left: Playback 0 [0%] [-74.00dB] [off]
  Front Right: Playback 0 [0%] [-74.00dB] [off]
............
............
 
Code:
[2020-07-09 17:49:59,571] {webserver.py:106} DEBUG - Web Server Started
[2020-07-09 17:50:00,057] {peppy.py:313} DEBUG - Audio Server Started
Did you see that? If not, please make sure that you set file.logging = True

The file is just empty and my settings are:
Code:
[logging]
file.logging = True
log.filename = /home/haegarthehorrible/opt/Peppy/peppy.log
console.logging = False
enable.stdout = True
show.mouse.events = False
I made a test and deleted peppy.log and did a reboot.
Then i get a new empty peppy.log. So path is correct...
 
Last edited:
I hope that 'pi' user has a write permission for that folder/file assuming that you are starting the player as 'pi' user.
User is "haegarthehorrible"

Owner and group of the peppy.log is "haegarthehorrible"
Permissions are 644
I can write and save text with nano in peppy.log
And since Peppy is creating that log by itself if it does not exist...

I will look at the alsa stuff later step by step.
I need to write down what works with what configuration.

Took a whole day to figure out that WLAN/Bluetooth command line stuff do get the Intel AX200 working.

Later i will get a JBL GO 2 speaker and then i can also test BT sound.
 
I guess i have to set "console.logging = True"

If i do that i see:
Code:
$ python3 peppy.py
pygame 1.9.6
Hello from the pygame community. [url=https://www.pygame.org/contribute.html]Contribute - pygame wiki[/url]
[2020-07-10 02:30:37,599] {peppy.py:313} DEBUG - Audio Server Started
and its also in the peppy.log.

If i reboot the log is empty again.
 
The console logging is helpful when you start the player in the terminal. It's not required for the file logging. I think if you disable the console logging then the file logging will be still working. Maybe the problem is in the current working directory when you start the player. Where did you install the player? Is it /home/haegarthehorrible/opt/Peppy/ ? Adding those two lines could help to identify the problem.
 
Last edited:
Yes that's the location.

Since Network does nothing - just showing "Loading..." the whole time, i thought lets see if the terminal now says something.
Yes it does:
Code:
[2020-07-10 02:46:45,081] {bluetoothutil.py:89} DEBUG - Starting bluetoothctl utility...
/bin/sh: 1: rfkill: not found
[2020-07-10 02:46:45,094] {bluetoothutil.py:94} DEBUG - Cannot start bluetoothctl utility: Command 'rfkill unblock bluetooth' returned non-zero exit status 127.
[2020-07-10 02:46:45,095] {bluetoothutil.py:96} DEBUG - bluetoothctl utility started
And its also in the peppy.log put the "rfkill: not found" part is not there:
Code:
[2020-07-10 02:46:45,081] {bluetoothutil.py:89} DEBUG - Starting bluetoothctl utility...
[2020-07-10 02:46:45,094] {bluetoothutil.py:94} DEBUG - Cannot start bluetoothctl utility: Command 'rfkill unblock bluetooth' returned non-zero exit status 127.
[2020-07-10 02:46:45,095] {bluetoothutil.py:96} DEBUG - bluetoothctl utility started
rfkill is there because i did install it when installing the Intel AX200.
But i need to run it with sudo:
Code:
$ sudo rfkill
ID TYPE      DEVICE      SOFT      HARD
 0 bluetooth hci0   unblocked unblocked
 1 wlan      phy0   unblocked unblocked
Code:
$ find / -name rfkill 2> /dev/null
/dev/rfkill
/sys/class/misc/rfkill
/sys/class/rfkill
/sys/devices/virtual/misc/rfkill
/sys/module/rfkill
/var/lib/systemd/rfkill
/usr/sbin/rfkill
/usr/lib/modules/5.4.0-0.bpo.4-amd64/kernel/net/rfkill
/usr/src/linux-headers-5.4.0-0.bpo.4-amd64/include/config/rfkill
/usr/share/doc/rfkill
/usr/share/bash-completion/completions/rfkill
 
You mean replacing:
Code:
except:
         pass
by
Code:
except Exception as e:
        print(e)
I already did that.

EDIT
Thats funny.
I made config.py its original code.

If i boot the machine the peppy.log is empty.
But if i do:
Code:
$ ps aux | grep python
haegart+   636  6.5  1.6 617580 63316 tty1     Sl   03:11   0:03 python3 peppy.py
haegart+   716  0.0  0.0   6072   884 pts/0    S+   03:12   0:00 grep python
haegarthehorrible@Cherry:~$ kill 636
haegarthehorrible@Cherry:~$ cd /home/haegarthehorrible/opt/Peppy
haegarthehorrible@Cherry:~/opt/Peppy$ export DISPLAY=:0.0
haegarthehorrible@Cherry:~/opt/Peppy$ python3 peppy.py
i have:
Code:
[2020-07-10 03:12:57,384] {peppy.py:313} DEBUG - Audio Server Started
in the peppy.log.

EDIT #2
I did look at bluetoothutil.py and see:
Code:
ASOUNDRC_FILENAME = "/home/pi/.asoundrc"
Isn't that hardcoding and bad practice?

So if somebody is using another username than "pi" that will give problems?
 
Last edited:
'rfkill' doesn't need 'sudo' on Raspberry OS. Probably changing that command to 'sudo rfkill unblock bluetooth' can also solve the problem (?) /usr/sbin is usually in the PATH.

How do you start the player after reboot? Do you start it as a service as a user 'haegarthehorrible'? I'm still trying to understand why file logging doesn't work after reboot.

Yes, hard coding is a bad practice, I'll change that constant to '~/.asoundrc'. So far the code and all docs assumed that the player will be installed by the 'pi' user. There were not so many adventurous guys who tried to install the player on the OS other than Raspberry OS or under another name :)

Thank you for your help and patience! Your findings will help to improve the player and save time for the others.
 
Even on Pi's i change the username :)

I auto login as haegarthehorrible:
Code:
~$ sudo usermod -a -G tty haegarthehorrible
~$ sudo nano /lib/udev/rules.d/50-udev-default.rules
>> CHANGE <<
SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620"
>> TO <<
SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0660"

~$ sudo mkdir -p /etc/systemd/system/getty@tty1.service.d
~$ sudo nano /etc/systemd/system/getty@tty1.service.d/override.conf
>> ADD <<
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin haegarthehorrible --noclear %I 38400 linux

~$ sudo systemctl enable [EMAIL="getty@tty1.service"]getty@tty1.service[/EMAIL]
For starting Peppy I use Xinitrc: Xinitrc - Debian Wiki

Code:
~$ nano ~/.profile
#Startx Automatically
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
. startx
logout
fi
Code:
~$ nano ~/.xinitrc
#!/bin/sh
cd /home/haegarthehorrible/opt/Peppy
exec python3 peppy.py
If Peppy will work on standard Debian it will run on every device :)
I will make a fresh install with user pi and see how that goes.
 
Last edited: