Please familiarise yourself with the forum, including policy on feature requests, rules & guidelines

USB HOST midi interface with Raspberry Zero

12

Hi guy's

I like to share my almost finished project to have "usb only controllers" work directly with de Deluge (or any other usb midi device for that matter) the Idea was brought to my attention on the Deluge Facebook group by Fabio Barbon.

Here is the deal:

Raspberry Zero with wifi and bluetooth (get them while they still out there, i think production stopped on those)
usb hub hat (it fits nicely on it)

How it works:

The Zero is running vanilla raspbian jessie in read only, so you can pull the power and don't risk sd-card corruption. The Zero wakes up and automatically connects the midi devices. thats it!

for maintenance, the Zero is configured to connect to my hotspot automatically, If it doesn't find my network, it will create a hotspot for you to connect to and that way you can ssh into it and configure what ever you like.

Thats how far i took it, software is running,, have to build a nice box to house the zero and 3 usb ports.. theoretically you could add a cheap usb to midi din adaptor and have an even more versatile device! i heard bluetooth midi works as well, i didn't test that

i used the following guides:

step one:

install Raspbian Jessie (i didn't go for Stretch because i couldn't get it boot properly in read only without errors)

step two:

get midi working:
https://stimresp.wordpress.com/2016/02/08/using-a-raspberry-pi-as-usb-midi-host/

to auto configure at boot i didn't use the cron methode as mentioned but i added the following to /etc/rc.local
aconnect 20:0 24:0
aconnect 24:0 20:0

step three:

set up the autohotspot:

http://www.raspberryconnect.com/network/item/331-raspberry-pi-auto-wifi-hotspot-switch-no-internet-routing

step four

make it read only:

https://learn.adafruit.com/read-only-raspberry-pi?view=all.

this, off course, works with any raspberry.

Comments

  • 0
    maxmanmaxman HamburgPosts: 8

    this is awesome.... trying with my zero now....

  • 0
    mrrafsmrrafs ukPosts: 63

    sIRwa2 this looks awesome. I assume you need to power the Raspberry via another usb lead and that provides the controller with juice?

  • 0
    TenebrousTenebrous EnglandPosts: 49

    For info, I came across another guide that may be of use too:
    https://neuma.studio/rpi-as-midi-host.html

    It covers:

    • automatically connecting devices together as and when they are plugged into the USB ports
    • setting up the Pi to act as a Bluetooth MIDI device
    • read-only mode.

    Hope it helps!

  • 0
    drbourbondrbourbon ItalyBeta Tester Posts: 55

    I've recently added instructions to connect a 128x64 1.3' OLED display (https://amazon.it/AZDelivery-Display-retroilluminato-Raspberry-gratuito/dp/B01L9GC470/ref=sr_1_2?ie=UTF8&qid=1550633976&sr=8-2&keywords=SSD1306) to the Raspberry for displaying active MIDI connected devices by name.

    This box works surprisingly well even with chained usb hubs. I am using this trick to control 6 synths with my deluge (3 raspberry usb ports, fourth is used to chain a 4 port standard usb hub).

  • 0
    TenebrousTenebrous EnglandPosts: 49

    @drbourbon said:
    I've recently added instructions to connect a 128x64 1.3' OLED display...

    Thanks for that! Works very well for me too.

  • 0
    Tricep3Tricep3 United KingdomPosts: 20

    Hi guys,

    This looks like an awesome way to chain lots of midi devices together. Does the Raspberry Pi basically act as a midi thru for all connected devices? For example, would all midi data received into the Raspberry Pi be sent to all devices that are connected?

    And what about if a Midi device that is connected gets its power from its usb port - does the raspberry pi draw enough power to power external hardware?

    Cheers,

    Alex

  • 0
    TenebrousTenebrous EnglandPosts: 49
    edited March 2019

    @Tricep3 said:
    ... would all midi data received into the Raspberry Pi be sent to all devices that are connected?

    Yep!

    @Tricep3 said:
    And what about if a Midi device that is connected gets its power from its usb port - does the raspberry pi draw enough power to power external hardware?

    You should have enough for a few simple devices. But the worst that could happen is the connected devices don't work reliably or don't power on.

    The best idea is to use a USB hub connected to the Pi - one that supports an additional separate power supply.

    FYI, the Pi's can supply power to USB:

    Pi 1: 500mA
    Pi 1B and Pi 2: 600mA, or 1.2A with max_usb_current=1
    Pi 3: 1.2A

    (I took this from https://github.com/superjamie/lazyweb/wiki/Raspberry-Pi-Power)

    Post edited by Tenebrous on
  • 0
    Tricep3Tricep3 United KingdomPosts: 20

    Thanks for the information Tenebrous! I was plan to power a Novation Launch Control XL and an Arturia Keystep with the Raspberry Pi but like you said it's probably best to have a powered usb hub in case I need more power. I found that the Keystep draws 500mA according to the manual. Does anyone know how much the Launch Control XL draws? I couldn't find it anywhere in the manual.

    Cheers

  • 0
    SquidgyBSquidgyB United KingdomBeta Tester Posts: 7

    I've modified my Deluge with a similar internal setup with two USB ports coming from a hub, a raspberry Pi Zero providing host connectivity with bluetooth along with an extended internal battery (6 cell 18650).

    I modified the Ruby connection script as I found the midi network was a little "shouty", with some devices which provide midi through on USB (with no option to turn this off) causing issues with clock and notes being repeated across the midi connections.

    I found that aconnect can also be used with the device name, rather than the numeric port, which made identifying and connecting to the Deluge much easier.

    I added the Deluge to the list in the same way as "Through", so as not to connect to itself, and I added a (blind) attempt to connect any secondary midi port on the device (my Monolouge has two USB midi ports, "0" being the output, and "1" being the input. As I want to control the Monologue from the Deluge, the original script only connects port "0", and the Monologue does not respond to midi, but can send midi to the Deluge on this connection).

    The result is the Deluge sits in the middle of the network, with to and from midi connections to each port on each device, and each device is unable to broadcast over the USB to each other, avoiding conflicts.

    It may not be useful to many (or any?) but I thought I'd put it here in case anyone is setting up something similar:

    #!/usr/bin/ruby
    #
    
    t = `aconnect -i -l`
    ports = []
    t.lines.each do |l|
      /client (\d*)\:/=~l
      port = $1
      # we skip empty lines, the "Through" port and the Deluge, so as not to connect to itself
      ports << port unless $1.nil? || $1 == '0' || /Through/=~l || /Deluge/=~l
    end
    
    ports.each do |p1| # we only connect to the "static" Deluge, once each way, for ports 0 and 1
      system  "aconnect #{p1}:0 'Deluge':0"
      system  "aconnect 'Deluge':0 #{p1}:0"
      system  "aconnect #{p1}:1 'Deluge':0"
      system  "aconnect 'Deluge':0 #{p1}:1"
    end
    

    As an aside, I also added nak_holdoff=0 to /boot/cmdline.txt, which seemed to fix some stuck note issues I had early on. I found this on a forum and it seemed to fix some issues i was having with a Keystep and a Seaboard Block.

  • 1
    SquidgyBSquidgyB United KingdomBeta Tester Posts: 7

    An extra note to this - the Raspbian image that's provided on the https://neuma.studio/rpi-as-midi-host.html blog seems to have issues with more than 3 USB devices on certain USB hubs - I tried on several different hubs and had issues when connecting devices on a 7-port hub.

    I managed to resolve this issue by upgrading (or rather re-imaging) to Buster Lite - the script for adding USB devices works fine now, I currently have 4 USB ports on the back, as well as the Deluge connected for a total of 5 potential devices.

    Still troubleshooting some weird power issues, but I think that's down to the USB hub and powerpack combo... I had to go through a number of different USB power banks to find one that functioned how I wanted, and the one I settled on still isn't perfect, as it reboots other devices when the USB hub is switched on, if other devices are powered on...

  • 0
    bionicalbionical New ZealandPosts: 5

    Awesome! Definitely going to try this. This may be a silly question, but would this work just as well using a micro-usb OTG hub? Love the look of the official Zero enclosure, so hoping I might be able to get that along with it.
    Example hub: https://tinyurl.com/y9mg5lh3

  • 0
    udelugeudeluge germanyPosts: 61

    Take a look at DietPi (https://dietpi.com/). Easy to set up, less running background services and can be configured via ssh without monitor. Read only support and more. I run all my Pi's (Camera, Home Automation) with DietPi.

    facebook is evil

  • 0
    EddyEddy Cologne, GermanyBeta Tester Posts: 292

    hope to bring this topic up again:
    I have tried with DietPi (as I couldn´t find any Jessie) and made it til the point of routing with success.
    Things that don´t work:
    the ruby script (I don´t know how to edit for my purpose)
    and the Readonly (what seems to be hazzle in DietPi)

    any answers would be welcome
    cheers Eddy

  • 0
    EddyEddy Cologne, GermanyBeta Tester Posts: 292

    I´ve tried now with Patchbox OS from Blokas but this doesn´t even boot on my Raspberry Zero W
    https://community.blokas.io/t/pi-zero-w-hangs-when-booting-with-usb-keyboard/1341/11

  • 0
    udelugeudeluge germanyPosts: 61

    have you done the read only over the drive-manager of diet-pi? (dietpi-launcher)?

    I don't know ruby but it looks like, the script only launches some command line tools. maby you have not installed ruby or the alsa stuff and aconnect on diet-pi?

    I have a blokas soundpi but haven't had time to install and test it.

    I have to fix some power problems first before I add more gear. I like to power everything from one usb source (usb charger with multiple outputs or power bank). Powering the deluge with a myVolts Ripcord 9V works but I have noise when I connect a 1010music blackbox, that is powered from the same 5V supply and connected to the input of the deluge. USB powered Zoom H6 on deluges output had added noise to but I could fix that with an isolated DC/DC converter. The blackbox needs to more power, so the DC/DC can't be used. I'm testing a modified 5V Ripcord for the blackbox at the moment, that filters the 5V.

    facebook is evil

Sign In or Register to comment.