Topic: Autostarting Pianoteq at boot time, Ubuntu Studio, sound devices

Hi there,

My aim is to set up my system such that switching it on is more or less as smooth as switching on a digital upright piano.

I have this setup:

- Pianoteq 5 Standard trial (which will purchased eventually)
- Laptop quad core 2.2GHz, 8 GB RAM
- SSD
- Ubuntu Studio 16.04.1 64 Bit

My system boots up in seconds.
I have set auto-login at boot-up.
I have created a script that starts Pianoteq 5.
I have added this script to the list of startup programs so it is automatically started upon login.

I noticed that Pianoteq is not able to connect to the ALSA sound this way. It comes up with the message that a sound device needs to be selected. I can then from the Pianoteq preferences select the audio I want and all is well.

If I put a 5 second sleep in the startup script before invoking Pianoteq then all is fine.

Has anyone experienced this? I suspect the system is still in the process of setting up the sound system so it is not available when Pianoteq tries to connect to it first time. Is there a way I can detect the sound system status?

I have tried to check the status of the sound system in the script but could not find anything.

Running "aplay -l" right at the beginning and then 5 s later shows no difference. I have experimented with modprobe too. No success.

Instead of waiting the full 5 seconds, I would like to check whether the audio system is ready and then start Pianoteq immediately after that.

Has anyone done this? Any help would be much appreciated.

Cheers,
Joerg

Re: Autostarting Pianoteq at boot time, Ubuntu Studio, sound devices

herrb wrote:

Hi there,

My aim is to set up my system such that switching it on is more or less as smooth as switching on a digital upright piano.

I have this setup:

- Pianoteq 5 Standard trial (which will purchased eventually)
- Laptop quad core 2.2GHz, 8 GB RAM
- SSD
- Ubuntu Studio 16.04.1 64 Bit

My system boots up in seconds.
I have set auto-login at boot-up.
I have created a script that starts Pianoteq 5.
I have added this script to the list of startup programs so it is automatically started upon login.

I noticed that Pianoteq is not able to connect to the ALSA sound this way. It comes up with the message that a sound device needs to be selected. I can then from the Pianoteq preferences select the audio I want and all is well.

If I put a 5 second sleep in the startup script before invoking Pianoteq then all is fine.

Has anyone experienced this? I suspect the system is still in the process of setting up the sound system so it is not available when Pianoteq tries to connect to it first time. Is there a way I can detect the sound system status?

I have tried to check the status of the sound system in the script but could not find anything.

Running "aplay -l" right at the beginning and then 5 s later shows no difference. I have experimented with modprobe too. No success.

Instead of waiting the full 5 seconds, I would like to check whether the audio system is ready and then start Pianoteq immediately after that.

Has anyone done this? Any help would be much appreciated.

Cheers,
Joerg

More easy than using a script:
You can use Jack

In the set up options, you can auto start Jack when the computer switches on, and inside Jack, there is an option to start what you want with a command line.

So, you switch the computer on, it starts Jack and Jack starts Pianoteq.

SK

Re: Autostarting Pianoteq at boot time, Ubuntu Studio, sound devices

herrb wrote:

Has anyone experienced this?

No, sorry, but maybe my mini-PC is "slow enough" to cause no race-condition (Celeron J1900). On a wireless PC I'm starting the pianoteq binary from KDE-Desktop's Autostart-folder (without sleep seconds). It is a Debian (Jessie), so no direct comparison.

I guess your Linux is based on systemd, the "mother of all processes". Maybe it is the right time to define your own "pianoteq.service". Those systemd service-files can contain all depends and prerequisites your binary needs to start.

You can inspect the boot-log of systemd with "journalctl -b".

Cheers

Last edited by groovy (16-09-2016 16:44)

Re: Autostarting Pianoteq at boot time, Ubuntu Studio, sound devices

Depends on what you mean by "startup" script.  Inside systemd/rc.local/etc, many services JACK/Pianoteq depends on may not be up yet.

Instead, I put my JACK+Pianoteq start script into Gnome/Mate's Startup Applications config so these programs autostart after login and after the graphical shell is completely launched.

Re: Autostarting Pianoteq at boot time, Ubuntu Studio, sound devices

Hi all,

Thanks for your responses.

I then thought that maybe Pulse Audio was not ready yet and tried to check for that -- so far to no avail. Of course, Pulse Audio is not of much concern to me, other than it showing up in the devices list in Pianoteq.

@stamkorg: your suggestion works a charm, thanks! I had wanted to keep the setup as simple as possible and choose ALSA hardware in Pianoteq, that way avoiding any layer of indirection (which I understand Jack introduces). I am not sure I understand whether using Jack will double latency or not.

@Mossy/groovy: I had thought starting Pianoteq from systemd would be more complex than through the login/autostart mechanism.

I'll keep trying the direct ALSA route and post here, should I find a solution.

Again thanks to all for taking the time to respond.

Cheers,
Joerg

Last edited by herrb (16-09-2016 08:16)

Re: Autostarting Pianoteq at boot time, Ubuntu Studio, sound devices

herrb wrote:

@stamkorg: your suggestion works a charm, thanks! I had wanted to keep the setup as simple as possible and choose ALSA hardware in Pianoteq, that way avoiding any layer of indirection (which I understand Jack introduces). I am not sure I understand whether using Jack will double latency or not.

To my knowledge, Jack is just a server that helps to connect applications.
I am not sure at all that it increases latency, it uses ALSA after all. But I am not a Linux specialist

Re: Autostarting Pianoteq at boot time, Ubuntu Studio, sound devices

There is no need for JACK if you don't run other audio programs (e.g. qsynth for other sounds, hydrogen drumkits, etc).  In this scenario, direct ALSA hardware is the best solution.

If you do run other audio programs, I would recommend using the realtime kernel in combination with JACK as I get the occasional dropped/warbled note with the regular kernel.  I use a login startup script that looks like so:

qjackctl
sleep 2
pianoteq

Last edited by Mossy (16-09-2016 16:40)