I have a new RPi disk image, on RPi3. It has Jack Installed on it. I use Pure Data to make music and I'm on v .49. I make my own midi controllers and I am trying to get midi in and out of Pure Data. Right now Pd does not see my midi controller at all, but Alsa does.

In terminal when I run: amidi -l

I get: IO hw:2,0,0 MIDI/MOCO for LUFA (that's my midi controller) 1

So Alsa does see my controller, the RPi is getting it.

When I run: pd -listdev

I see my midi controller listed as an audio input and output device (it's not audio device, just midi). At the bottom it says:

no midi input devices found
no midi output devices found

I spent several hours trying to figure out Jack. I tried installing Qjackctl but it won't compile (Arrgh so frustrating).

Ultimately I need to run this computer headless, so if I do use Jack I want to set up a shell script and have it configure automaticlly, but really I don't want to use Jack at all if possible.

Is there someplace with command line instructions to control/configure Jack? I haven't been able to find it.

Can I configure ALSA to send my midi data directly to Pure Data?

I am guessing this problem has showed up before. What is the best way to resolve this?

So I have a solution, but it's not a great solution. I am able to connect my midi devices using aconnect, but it takes like 30 seconds after Pd has launched to achieve this, and, because of the nature of my setup, I have to quit Pd and restart it for every song, and wait 30 seconds again. And I feel like that's too long.

So I want to figure out JACK. If I could create a JACK midi client and when my Pi boots up I can have Pd set to receive midi from Jack. And I can have my midi controller, at boot up, connect to alsa midi, and alsa midi connect to Jack. And only have to create these connections when I boot up.

So my question is: In the terminal how do I create a midi client in Jack? I've been searching and I can't seem to find it. I typed "jackd" in the terminal and i see all these possible commands, but I don't see how to create a midi client or midi port.

Again, first try different midi drivers for jack. If you're lucky the jack midi ports will show up after started starting pd. If not, try ajmidid which creates a jack midi port for every ALSA midi port on your system.

@flappix thank you for that very detailed reply. I think I followed along. It took a while, but I was able to set everything up with qjack.

So now, I have my midi controller plugged in at startup, I launch qjackctl from the terminal and load my patchbay preset (manually) and hit "activate."

then when I launch pure data everything works! if I close a pure data patch, quit the program and open another patch, everything is still connected, so this is a pretty huge improvement for me.

Now my question (hopefully my last for awhile) Is there a way to load, and activate a qjackctl patchbay preset from command line? or Terminal? I would like this to happen right at bootup and i saw some options to "Execute script on Startup." Is that where the preset should be loaded?

which sort of details my problem/request of trying to load and activate a qjackctl patchbay preset from terminal. I want this to ultimately happen automatically with a shell script.

So in terminal I navigated to the folder of my preset and typed:

qjackctl --active-patchbay=mypresetname.xml

where my patchbay preset name is there instead of "mypresetname." This launches qjackctl, but doesn't seem to load the preset and doesn't activate anything. The only way I can load my preset is to open the patch bay, hit load and navigate to my preset. Then after it's loaded i have to press "activate."

Also, maybe this is part of the problem. When I open qjackctl I get this message:

libEGL warning: DRI2: failed to authenticate

** (qjackctl:4058): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnkown: The name org.a11y.Bus was not provided by any .service files

So maybe I am missing something, perhaps I need some other installation to run qjackctl properly. I don't know. Let me know if anyone has a clue about these things.

In Qjackctl in the settings, under Misc I checked a few boxes relating to Enable D-bus.

Now when I run the following line in terminal:

qjackctl --active-patchbay=/home/pi/folder/mypresetname.xml

It does launch qjackctl with my patch loaded and activated. But when I launch Pd I still have to go into Qjack and de-activate the patchbay, then activate it again to work. I even have to do this if I launched Pd first. But at least it is loading my patch. I am also still getting the error message I listed in the previous post.

I am still trying some things out, and trying to find a way to make this all happen automatically in a headless Rpi.

Any suggestions or help is appreciated, I will keep posting if I make some progress.

in Qjackctl, Settings, Options, I selected my patchbay preset file, and clicked "activate Patchbay persistence." In order for that to open I also had to click, in Settings, Misc, "Enable D-Bus interface" and "Enable JACK D-Bus"

And I added Qjackctl as a startup flag in Raspberry Pi startup folder, which is in:

/home/pi/.config/lxsession/?LXDE-pi

Now Qjackctl opens when I startup my computer with the right midi routings, and the patchbay is "activated." However the midi still doesn't work! I have to manually de-activate it, then activate it again for it to work. I tried every combination of starting Pd then Qjack, etc. Nothing worked. I also tried the different midi options in Qjackctl, like raw, none and seq. And in the parameters advnced i tried a lot of different input and output options. Some of those made the audio not work. But none of them fixed the problem.

I have a feeling the D-Bus error message I keep getting is not the problem, as I was able to eliminate it, but it only made it so that even when I activated the patchbay it still didn't work.

I went back to a2jmidid and tried to get that going. I am getting an ERROR with that too:

Basically where I am at is I have everything opening up fine, and routed fine, I just have to find a way to deactivate the midi patchbay, then activate it again. I ran: qjackctl --help, and it seems with the options I am given I might not be able to achieve this

I am so close to figuring this out, but it sort of seems impossible with the options I am given in qjackctl.

If anyone has ANY insight or ideas I would really really love to hear them, I think I am all out of ideas and options that I can think of.

Have you looked in to the Zynthian Project? It's a whole synthesizer platform based on the Raspberry Pi. It looks a bit daunting but it's possible to get it going with pretty minimal resources. http://zynthian.org/

qjackctl is a GUI app and needs X, so not headless. There's jack_control to do the routing on the command line, at least for jack1. Although not sure how you know the "names" of things without a gui and qjackctl. I made a youtube video years ago on midi the hardware with a lot of the cli options. Ending with some of the easier gui options. It can be done, even headless. Although it's much easier with a gui, especially if you're going to add pulseaudio into the mix. I use a RPi 3B+ with the 7" touch screen as a pulse over jack sound server. The newer jack2 / jackdbus method is a bit different than my youtube video from long ago.

jack_connect, not jack_control for my previous. Although mostly aconnect in the video. The jack_control is more of the jackdbus method to stop / start / exit. And the various other bits normally done on a single command with jack1, like select which card, rate, bits, channels, and whatnot.