Topic: Pianoteq headless as service
I've seen this approach proposed years ago in this forum. Recently I reviewed it with a slight different setup on my Raspberry Pi 5 headless, to be managed by buttons of an external Android app. I want to share it here to listen eventual comments or suggestions. The service file is the following:
pianoteq.service
[Unit]
Description=Pianoteq headless
[Service]
Type=simple
User=pi
LimitRTPRIO=infinity
LimitMEMLOCK=infinity
LimitRTTIME=infinity
EnvironmentFile = /home/pi/Pianoteq\ 8\ STAGE/arm-64bit/preset
ExecStartPre=/usr/bin/sudo /usr/bin/cpufreq-set -g performance
ExecStart=/home/pi/'Pianoteq 8 STAGE'/arm-64bit/'Pianoteq 8 STAGE' --headless --multicore max --preset $PS
ExecStopPost=/usr/bin/sudo /usr/bin/cpufreq-set -g ondemand
KillMode=process
[Install]
WantedBy=multi-user.target
I found that calling cpufreq-set only once without the option -c sets the governor to all the cores automatically.
When I first used this service I found several messages in the logs similar to these:
...
Midi thread could not acquire real-time scheduling, error 1 -- Operation not permitted
Alsa thread could not acquire real-time scheduling, error 1 -- Operation not permitted
Multi-core: could not acquire real-time scheduling, error 1 -- Operation not permitted
...
Apparently it was not causing any problem, but digging in the web I found that the system does not complain anymore if I set the LimitXXXXXX=infinity as in my file. I learned that this is related to realtime scheduling, but I cannot understand the possible implications of it. Anyone knows if there coud be unwanted side effects?
In order to change the preset I then create a series of scripts similar to this:
#!/bin/bash
echo "Starting Pianoteq headless:" ; echo "HB Steinway D Classical"
# Overwrite the variable declaration in the preset file
echo "PS=\"HB\\ Steinway\\ D\\ Classical\"" > /home/pi/Pianoteq\ 8\ STAGE/arm-64bit/preset
# Start Pianoteq headless service
sudo systemctl restart pianoteq
and associate each script with a button so that I may change the instrument easily without accessing the graphic interface. What is your thought about this?