I found a website that describes how to turn a Raspbery Pi that runs your average basic Raspbian into a hassle free Midi host! You do not have to connect the Pi to a monitor and keyboard and type in commands. It wil "auto-sense" that you've inserted Midi cables in the Pi and connect them (via the command aconnect). What you need is a Pi, some battery power (e.g. a 4 X AA battery to USB power thingy from Aliexpress, € 2.25) and a USB to DIN cable (link Aliexpress, € 4). On this website the procedure is described and the author refers to this website from where he got the Ruby script. However, he made a typo in copying the Ruby script, so I'll post my procedure here.
1. sudo apt-get install ruby git
2. Configuring automatic Midi connection. Issue the command sudo nano /usr/local/bin/connectall.rb and copy the following content:
Code: Select all
#!/usr/bin/ruby
#
t = `aconnect -i -l`
ports = []
t.lines.each do |l|
/client (\d*)\:/=~l
port = $1
# we skip empty lines and the "Through" port
ports << port unless $1.nil? || $1 == '0' || /Through/=~l
end
ports.each do |p1|
ports.each do |p2|
unless p1 == p2 # probably not a good idea to connect a port to itself
system "aconnect #{p1}:0 #{p2}:0"
end
end
end
Code: Select all
sudo chmod +x /usr/local/bin/connectall.rb
4. Configure automatic MIDI connection/disconnection on USB device connect/disconnect:
Code: Select all
sudo nano /etc/udev/rules.d/33-midiusb.rules
Code: Select all
ACTION=="add|remove", SUBSYSTEM=="usb", DRIVER=="usb", RUN+="/usr/local/bin/connectall.rb"
5. Issue the following commands:
Code: Select all
sudo udevadm control --reload
sudo service udev restart
Code: Select all
sudo nano /lib/systemd/system/midi.service
Code: Select all
[Unit]
Description=Initial USB MIDI connect
[Service]
ExecStart=/usr/local/bin/connectall.rb
[Install]
WantedBy=multi-user.target
Code: Select all
sudo systemctl daemon-reload
sudo systemctl enable midi.service
sudo systemctl start midi.service
P.S. Your Pi will still "behave" like your average basic Pi running Raspbian so no reason not to do this.