Midi devices in PD

Hi Forum,

Is there a possibility to distinguish MIDI devices in PD on PatchboxOS? If I try to increase the MIDI Import count greater than 1 in Alsa Midi Settings, it will always switch back to 1. I tried launching PD NOT with the button to avoid the input flags set by the btn-script but this doesn’t have an effect.

In Patchage I can see the different devices by name but PD has only one input also there.

thanks Falk

ok I kept playing with that and found an interesting thing: It is possible to change the device input count only the number PD displays in the pref window always sticks at 1. I had to increase the value and press apply this immediately increases the count in Patchage to 4 and even after a reboot it still is 4. To address those devices its via MIDI channel count dev1 1-16, dev2: 17-32 etc
One question ist left over:
if I patch the devices in Patchage on different Ports eg my second MIDI controller to Port2 it will work but after reboot its all reconnected to port 1 again. Is there a way to save the Patchage state?
thanks

Falk

disabling amidiauto should help

Yes, amidiauto will reconnect every hw device to the first software port. You may edit /etc/amidiauto.conf rules file to customize the behavior a bit (search forum posts for some examples of the configuration). It does currently work with only the first port of multi-port software or hardware. We plan to add multi-port support for amidiauto in a future update.

Not sure if there’s other means to have the connections set up automatically. There’s always ‘udev rules’ you could create, like discussed here: Midi connection manager - they get executed automatically on various hardware events, like USB device getting connected to the system.

Hi everNoob and Giedrius,

thanks for your advice I will check it and report if it and how worked out. So far I am working with 4 USB devices connected to the pi, 2 of them using Mackie protocol which makes it a bit complicated at one stage to not interfere with each other since Mackie protocol can not be split by midi channel. in short it would be great to have official multi-port support on patchboxOS.

cheers Falk

disable amidiauto did not fix it here:

  1. I disabled amidiauto with sudo systemctl disable amidiauto and got a response thas is was disabled

  2. I lauchnched PD with the connected MIDIdevices, changed some routing in patcharg and did a reboot.

  3. launching PD and opening patcharg after showed me that all connections are back to port 1

After rebooting, what does sudo systemctl status amidiauto say? And what does this command output:

ps -ef | grep amidiauto

Btw, Patchage won’t remember the connections you’ve made, that’s why amidiauto is there in the first place, to do the connections automatically :slight_smile:

I checked with the status and it seems that sudo sudo systemctl disable amidiauto does not work ans seems to be active after disabling:

patch@patchbox:~ $ sudo systemctl disable amidiauto
Removed /etc/systemd/system/multi-user.target.wants/amidiauto.service.
patch@patchbox:~ $ sudo systemctl status amidiauto

  • amidiauto.service - ALSA MIDI autoconnect daemon
    Loaded: loaded (/lib/systemd/system/amidiauto.service; disabled; vendor preset: en
    Active: active (running) since Mon 2020-10-26 16:27:46 CET; 14min ago
    Main PID: 753 (amidiauto)
    Tasks: 1 (limit: 4033)
    Memory: 876.0K
    CGroup: /system.slice/amidiauto.service
    `-753 /usr/bin/amidiauto

Okt 26 16:27:46 patchbox systemd[1]: Started ALSA MIDI autoconnect daemon.
Okt 26 16:27:46 patchbox amidiauto[753]: Reading ‘/etc/amidiauto.conf’ failed! (-2)
Okt 26 16:27:46 patchbox amidiauto[753]: Allowing ‘’ → '
lines 1-12/12 (END)

stoping it seems to work until rebooting

patch@patchbox:~ $ sudo systemctl stop amidiauto
patch@patchbox:~ $ sudo systemctl status amidiauto

  • amidiauto.service - ALSA MIDI autoconnect daemon
    Loaded: loaded (/lib/systemd/system/amidiauto.service; disabled; vendor prese
    Active: inactive (dead)

Okt 26 16:27:46 patchbox systemd[1]: Started ALSA MIDI autoconnect daemon.
Okt 26 16:27:46 patchbox amidiauto[753]: Reading ‘/etc/amidiauto.conf’ failed! (
Okt 26 16:27:46 patchbox amidiauto[753]: Allowing ‘’ → '
Okt 26 16:45:38 patchbox systemd[1]: Stopping ALSA MIDI autoconnect daemon…
Okt 26 16:45:38 patchbox systemd[1]: amidiauto.service: Main process exited, cod
Okt 26 16:45:38 patchbox systemd[1]: amidiauto.service: Succeeded.
Okt 26 16:45:38 patchbox systemd[1]: Stopped ALSA MIDI autoconnect daemon.

patch@patchbox:~ $ ps -ef | grep amidiauto
patch 1518 1471 0 16:47 pts/1 00:00:00 grep --color=auto amidiauto
patch@patchbox:~ $

and after a reboot is is back on:

patch@patchbox:~ $ sudo systemctl status amidiauto

  • amidiauto.service - ALSA MIDI autoconnect daemon
    Loaded: loaded (/lib/systemd/system/amidiauto.service; enabled; vendor preset
    Active: active (running) since Mon 2020-10-26 16:48:40 CET; 34s ago
    Main PID: 745 (amidiauto)
    Tasks: 1 (limit: 4033)
    Memory: 788.0K
    CGroup: /system.slice/amidiauto.service
    `-745 /usr/bin/amidiauto

Okt 26 16:48:40 patchbox systemd[1]: Started ALSA MIDI autoconnect daemon.
Okt 26 16:48:40 patchbox amidiauto[745]: Reading ‘/etc/amidiauto.conf’ failed! (
Okt 26 16:48:40 patchbox amidiauto[745]: Allowing ‘’ → '
lines 1-12/12 (END)

patch@patchbox:~ $ ps -ef | grep amidiauto
root 745 1 0 16:48 ? 00:00:00 /usr/bin/amidiauto
root 1146 1133 0 16:49 pts/0 00:00:00 sudo systemctl status amidiauto
root 1154 1146 0 16:49 pts/0 00:00:00 systemctl status amidiauto
patch 1175 1168 0 16:50 pts/1 00:00:00 grep --color=auto amidiauto
patch@patchbox:~ $

Ah, it gets started together with the Pure Data Patchbox module. Try running this command:

sudo systemctl mask amidiauto

This masking thing should allow telling the Patchbox Module manager to keep particular modules that normally would get started stopped.

well masking works in a way but If I mask, connect stuff and reboot everything is disconnected after. It also won´t connect after PD launch

I believe the problem ls after booting the OS and before starting PD since the virtual pd ports are not there for connection before. What it needs is some service which makes connections after pd has launched. In Max on OSX and Win there is an external to use the terminal. I didnt find one in PD, If there were one it could call some amidi commands to make connections after pd launch

That’s the purpose of amidiauto, to connect things together dynamically and on boot :slight_smile: Just that it currently supports connections to the first port of an ALSA client…

Check out the Pure Data launcher script: /usr/local/patchbox-modules/upredata/launch.sh - it has a block for delayed aconnect calls, you could modify that locally according to your needs.

Hi Giedrius, thats a good plan I will try it as soon as I got time. Thnks fpr your help

Falk

1 Like