• 1
    Choose a USB hub
    To cut costs I chose a cheap Chinese USB hub: https://www.aliexpress.com/item/4000040290804.html. It's built very cheaply but it works.
  • 2
    Install an operating system onto Raspberry Pi Zero
  • 3
    Set up Raspberry Pi to automatically connect MIDI

    Place the following files on your desktop (/home/pi/Desktop):


    connect-midi.sh

    PORTS=`aconnect -l | fgrep "client" | fgrep -v "client 0:" | fgrep -v "client 14:" | grep -o "client [0-9]\+:" | grep -o "[0-9]\+"`;
    
    for port1 in $PORTS; do
        for port2 in $PORTS; do
            if [[ "$port1" != "$port2" ]]; then
                aconnect $port1 $port2
            fi
        done
    done 

    connect-midi-loop.sh

    while :; do
        /home/pi/Desktop/connect-midi.sh
        sleep 1
    done 

    Change permissions for both of these files to allow executing them by running these commands in console:

    chmod +x /home/pi/Desktop/connect-midi.sh
    chmod +x /home/pi/Desktop/connect-midi-loop.sh

    To test if these scripts work connect the USB hub using a USB OTG adapter to the Raspberry Pi. Run this command and then connect multiple MIDI devices to the USB hub to check if MIDI messages sent by one device are received by other devices:

    /home/pi/Desktop/connect-midi-loop.sh 


    Finally, add this to the end of /etc/profile (it'll automatically start running connect-midi-loop.sh in the background when Pi Zero starts up):

    /home/pi/Desktop/connect-midi-loop.sh 2> /dev/null &