i2C to MIDI on Raspberry PI

Hey guys wasn’t sure where this fits so making new topic.

I managed to get hold of Pi4 and planning to use it as sequencer with ORCΛ ideally adding MIDI din outs to 1) interface with Buchla 225e and 2) via i2C with ER301.

Question here @okyeron @TheTechnobear have you possibly tried sending MIDI via i2C? I am looking at options of running Pi4 with Hyperpixel screen which has the GPIO extension i2C interface. Planning to use Pd and @neauoire ORCΛ but wonder if its possible at all and if I’m missing something totally obvious or basic here…

I see @scanner_darkly was exploring that with Teletype but here it is slightly different issue/hardware and wonder if you managed to send it from Teletype to Machinedrum?
I also found @Drillionaire post on OD forum and experiments with Teensy

Ultimate sollution would be to link to my Buchla 225e/ Machinedrum so need MIDI din.

Here are some experiments. But I’m keen to skip the laptop with interface here. Wonder if you have any ideas? Any thoughts much appreciated.

1 Like

This is way above my head, but I wanna keep an eye on this :slight_smile:

1 Like

(Discourse ate my longer reply, so here’s a do over).

Important thing to note - MIDI and i2c are two very different things. There is no way of “sending MIDI via i2C”

For MIDI you just need a MIDI-DIN solution - that could be a USBMIDI device or something wired directly to the Pi’s GPIOs.

For i2c there’s not really a “ready to use” solution for sending commands from a Pi to the ER301. You’d need to create that (using python or something perhaps).

Or… perhaps ORCΛ could be hacked to add a send i2c operator to use with the ER301 (or other devices).

I’m pretty sure if someone sent me or @neauoire an ER301 to hack on, we could come up with something :grinning:

Same here @neauoire :slight_smile: trying to push my internal tech boundaries :wink:

@okyeron really good idea about i2c operator in ORCΛ! Think it would be ace! Seriously tho I was thinking of dealing with it in Pure Data or as you say Python. I think there might be externals that can do it.

I know its different protocol I’m just trying to think of ways of using it to send MIDI data as there are outputs on Pi. Ideally, I don’t want to add another MIDI box to link Pi with other gear. Worst case scenario Pi sound would sort it out, but I won’t be able to use the screen as it takes GPIO ports. https://blokas.io/pisound/docs/Specs/
not sure if you can multi them :smile:

Also, there is not many USB MIDI boxes that can talk to Raspberry PI or Linux. Idea is to streamline it and make it in small raspberry pi box.

The i2c and ER301 communication will be easier once crow module is out too.

You should speak with Brian from OD about ER301 :wink:

if you use I2C for midi you are going to end up using something as a bridge… e.g. something like an arduino.

however I think the issue is more the software on the rPI ,
since it will have to speak ‘i2c’ (and how you chose to encode midi over it)
OR you write a small alsa app that exposes a virtual midi port that then does that mapping for you.
(then any midi enabled app can use this connection)

i.e. we end up with

-----------RPI--------------------------          ------arduino---
PD -> virtual midi -> alsa midi-2-i2c app -i2c->  i2c-2-midi sketch --> usb or midi din output     

but all seems like a faff, seeing as rPI has usb hub , and a USB->MIDI din cable is like $5-10 :wink:

but perhaps im missing something?

Id only see i2c as perhaps preferable if I wanted to write my own custom protocol (*),
so Id want to write both ends of the comms and interface to apps thru an api


(*) main purpose, and Ive been considering this for one project recently, is either optimisation or due to existing protocols being inadequate for purpose.
(e.g. ive a use-case where midi does not have enough for my needs but OSC is a bit heavy)

1 Like

I could be wrong but if the device is “class-compliant” usbmidi it should just work.

I have tens of usbmidi devices and they all talk to Raspberry Pi just fine.

It’s possible there are issues with some specific softwares and things like multi-interface devices, but that’s not really a hardware problem.

Again as mentioned above there are $5-10 usbmidi to din solutions widely available.

1 Like

From a hardware standpoint, MIDI is just a serial interface, set the correct baud rate (31250) and use the serial GPIO raspberry Pi pins, and as long as only 3.3v MIDI talks to the raspberry Pi, everything will just work. It wouldn’t be spec correct, you’d need an optocoupler and some resistors for that, but it should work. It’s not i2c, but it’s still using the built in GPIO. There are plenty of Arduino tutorials for this, which could easily be adapted for the raspberry Pi

1 Like

still worth clarifying: are you specifically interested in MIDI specifically… or are you using that as shorthand for “note/trigger data and other metadata, the kind that MIDI encodes as continuous controllers or NRPNs”?

The protocol that Teletype communicates with over I2C uses much higher resolution numbers, for instance, and if you’re in control of ‘both ends’ (ie: you are responsible for firmware both ends, such as between a custom device and an Orca module you write)… there may be more appropriate choices. Similarly, saying ‘MIDI’ but not handling CCs on the software end feels like it sells MIDI short.

My other key note about I2C is that it is absolutely not designed to be hot-plugged - you’ll at the least crash something if you do that. It’s designed to be permanently connected inside circuits; monome popularised it as a ‘bus’ that would still be permanently connected inside a case. MIDI connectors and electronic specs are super-robust, and you can yank and replug them simply. The stereo jack plug on 16n was a compromise: it’s reasonably secure, and works well as a connection, but jacks encourage hot-plugging which just isn’t possible.

3 Likes

Hey thanks for insightful comments. You are correct and I should have been more precise. I meant MIDI notes, and CC tho in my case studies (Machinedrum and 225e) notes and triggers/ CC will be enough.

I wasn’t aware of i2C not being hot-plugged as it seems to be used that way with Buchla 222e or 16n or ER301-teletype tho latter ones is more in beta/ development as I understand. Saying that practically I would plug that in/out before and after the gig.

You can’t plug in i2c cables for 16n or Teletype, etc while things are powered on.

1 Like

thanks @TheTechnobear @okyeron yes I need to still try midi interfaces with RPI. I tested USB to MIDI adapter and it wasn’t working even with Mac. Need more tests here. I have Elektron TM-1 will see if that works. If thats the case then yeah its much easier solution.

As for i2c that was idea to control ER301 specifically and with Raspberry PI. Either with Pure Data or ORCA. Would be neat to access it with one cable. This is kind of separate issue and indeed might need more work and time then I have. Using Norns might be a solution here? or extension module? but then not sure what is the state of running pure data on it at the moment?

I see. I haven’t used i2c cable yet :slight_smile: but thats not a big issue tbh. Would just have to watch and save stuff before rebooting if needed.

Does Er301 have native support for i2c?
Published protocol details?

If so would be easier enough to then knock up PD external for its i2c protocol.

Note sure I follow what you think norms adds to the mix - i2c is well supported on rPI , adding another box (generally) tends to just complicate matters - more points of failure etc

trust me, it is not hot-plugged on any of those things. If you get a 16n, you’ll find the legend DO NOT HOT PLUG by the I2C jack. This is not because they are “in development”; it’s because the connection bus just doesn’t support it.

1 Like

Nor on 200e, for the record. Module discovery and address assignment happens on boot.

Seems like a pd external would be handy.

The protocol is the same as used by Monome modules and I believe there’s a “ii.h” header which defines addresses, etc. (will find link in a bit)

Edit: Some monome source files: https://github.com/monome/libavr32/blob/master/src/ii.h
https://github.com/monome/libavr32/blob/master/src/i2c.h
https://github.com/monome/libavr32/blob/master/src/i2c.c

Also wanted to chime in on this:

The norns software (and hardware) do not support i2c communication to other devices - so no, norns is not a solution here. (because of this I abandoned the idea of including i2c ports/headers on my Fates board - as it looked like it would be too difficult to support in the long run)

The crow module will have i2c capabilities and may be the swiss-army knife @koshi is looking for.

1 Like

Sorry, yeah I meant crow module with norns and it should work with PI.

Good idea about PD i2c external @TheTechnobear and i found this table here. Haven’t tried it yet tho.

Meanwhile my Pi4 bricked 3x microSD cards to the point that I can’t see partitions even with GParted on linux. I am being sent the new one…

Yeah I’d hope/expect crow will work with many things.

I must admit I don’t have any modules with i2c , so it’s of limited use for me

i think the easiest is to get Pi4 talk to MIDI using the suggestions in this thread. for er-301 you have several options:

  • use some MIDI to CV converter and er-301 CV inputs

  • add i2c support to Pi4 (monome i2c protocol is very simple, adding er-301 support should be trivial once you get the hardware working, protocol details here)

  • have something that can convert MIDI to monome i2c protocol - enigma (the device @okyeron and i are working on) could do this but it’s still in early prototype stage. or if you have 16n faderbank you could use it as a MIDI to i2c converter - it will convert either minijack MIDI or USB MIDI to er-301 or just friends i2c commands (firmware here: https://github.com/scanner-darkly/16n/tree/tom/firmware/_16n_faderbank_firmware)

this would be a pretty convoluted way to send MID from Pi4 - easier to just send it direct from Pi4, but for completeness sake i’ll mention that i did try adding MIDI support to teletype but wasn’t successful.

2 Likes

No I meant doing it the same way you did but using PI instead of Teletype. I need to get hold of USB to MIDI cable and test it again.

Cool idea with 16n! I didn’t know you can do it.

i2c support for PI sounds good will investigate that, thanks for the link.
Keen to sort out midi first as have more uses for it too.

1 Like