Can't start a headless JACK server

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
emilreloaded
Posts: 3
Joined: Sat Feb 22, 2020 2:24 pm

Can't start a headless JACK server

Post by emilreloaded »

I've dusted off some old hardware with a project in mind. My goal is to configure my old Pi 2 as a sound-card for an M-Audio Hammer 88 keyboard. I've been at this a couple of days now, reviewing posts and man pages and the like, and I'm afraid I finally have to ask assistance directly.

I have configured a shell script that launches:
  • a JACK server,
  • FLUID Synth with the desired options, and
  • connects the keyboard with aconnect.
However, I cannot get it to execute unless I run it through a root-privileged x session (sudo startx).

While it's certainly possible for me to launch it once, my goal is to hand it off to a six-year-old child so that she can use it as a standalone instrument. The goal is to plug it in, flip the switch on a surge protector, and have it producing sound in under a minute.

Is it possible to automate this process with the tools I've described, or am I missing a critical component?

Thanks.
User avatar
MichaIng
Site Admin
Posts: 2294
Joined: Sat Nov 18, 2017 6:21 pm

Re: Can't start a headless JACK server

Post by MichaIng »

Just a little note about the permissions: Assure that the login user is part of the audio group: usermod -aG audio <username>
For direct graphics and rendering access there are two other groups:
usermod -aG video <username>
usermod -aG render <username>

Is this a GUI application or why must it execute from an x session? And do you mean it must run from within a desktop session or can you start it directly as X application, e.g. via xinit as well?

Generally I would use a systemd service to start things automatically on boot and as early as possible boot stage, but if it must run from within desktop session, then you need to use desktop auto login and some desktop specific auto launch option.
emilreloaded
Posts: 3
Joined: Sat Feb 22, 2020 2:24 pm

Re: Can't start a headless JACK server

Post by emilreloaded »

Thank you for the rapid reply!
So, I've tried a couple approaches to this. The first was to use the dietpi custom.sh not option (apologies for the ambiguity, I'm away from the house at the moment), and I kept getting an X11 $DISPLAY error even though everything was command line. I believe I've added my root login to the audio group but I'll double check.

It's not a gui application. I don't know why it needs an x session, honestly. If I start the desktop, I can run it in a terminal window with no GUI. It uses dbus as a service, which I'm not terribly familiar with, but the reading I've done seems to indicate it needs some flavor of display.

I'll try to sort the dbus and systemd as soon as I get back, and provide some more complete information.
Thanks again.
User avatar
MichaIng
Site Admin
Posts: 2294
Joined: Sat Nov 18, 2017 6:21 pm

Re: Can't start a headless JACK server

Post by MichaIng »

Okay so first dbus needs to be installed then and probably systemd-logind unmasked (both done by default when you install a desktop through dietpi-software:

Code: Select all

systemctl unmask systemd-logind
G_AGI dbus libpam-systemd
systemctl start systemd-logind
If starting the program from console (outside of desktop session) fails with X11 error then it is probably still possible to invoke it via xinit <program_command>.
emilreloaded
Posts: 3
Joined: Sat Feb 22, 2020 2:24 pm

Re: Can't start a headless JACK server

Post by emilreloaded »

Hmm.
So, I've placed the code from the last post at the beginning of my '/var/lib/dietpi/dietpi-autostart/custom.sh' file and I get the message

Code: Select all

line 3: G_AGI: command not found
I did manage to get the JACK server up and running in a logged in session by pointing the .bashrc file to another script, but then the system refused to move beyond that step. Using xinit had the same effect.
The standard cancel (^C) and suspend (^Z) keystrokes didn't work, and I had to ssh in on another client to kill the processes.
Shoving JACK into a background process seems to allow the server to launch and lets me bring up fluidsynth, but then the audio ends up glitchy and I get the message

Code: Select all

JackAudioDriver::ProcessGraphAsyncMaster: Process error
when I hit too many notes.

I'm fiddling with the jackd start conditions now to see if I can resolve it. I am, however, open to suggestions on optimization.

edit: It immediately occurs to me that the code previously provided was meant as a one-time execution. So, um. Thanks!
Post Reply