midi in and midi out

heres a pd patch that’ll help you work out automatic midi assignments


so we don’t have to manually connect all the time we can write some code that directly connects our devices with their “machine names”.

first off makes sure your using ALSA-MIDI. Then in midi settings tell it how many ports you have (in my example I have 3 ports in and 3 ports out, two midi interfaces, one with 1 output and 1 input, and my trusty midisport with 2 inputs and 2 outputs)


in a terminal window type

aconnect -i

aconnect -o

aconnect -l

this will list all the midi ports (both in and out) on the raspberry pi. In pd i use the shell object to send terminal messages.for instance

sudo aconnect 128:3 24:0    connects the midi out of pd to the output of one of my midi interfaces (the CH345)

sudo aconnect 24:0 128:0    connects the  the midi in of pd to the midi input of one of my midi devices (the CH345)

if you open the example patch you’ll see the first thing it does is send these aconnect messages to join all 3 midi ins and all 3 midi outs

All these numbers might seem confusing but if you have a look in the terminal window you can see what ever codes are used to identify the different devices. just plug your device into the pi and aconnet -l

double click on the picture below and see what i mean.it’s all laid bare in the terminal window.




alternatively a standard midi connect interface  is available, the Aconnectgui.  This won’t remember its settings if you shut the machine down or change midi devices.