Page 1 of 1

Using MIDI for RPC

Posted: Sat Apr 13, 2019 5:25 pm
by Basslint
Many synths have nice features which can't be configured via MIDI, because MIDI offers a limited set of commands. At the same time, OSC supports is not that widespread.

I was thinking that maybe MIDI ports could be used to send arbitrary data, in a way similar to how RPCs work.

This way you could for example write a Python program that fully interacts with a running ZynaddsubFX instance easily, without any API calls. Just connect it to the JACK/ALSA MIDI in port, send the commands and (if necessary) get the results back from the MIDI out port.

Was this ever attempted? Is there a way to use MIDI to send arbitrary data?

Re: Using MIDI for RPC

Posted: Sun Apr 14, 2019 4:44 pm
by tramp
Why do you want that?
First point is, you need to abuse a protocol to do so, this abuse must be supported by the application you want to serve by this.
Much easier is a socket to use, which could do all that, without abusing a protocol. A (rpc) socket could as well be used across networks, so you could control the app in question from a other PC or tablet or even from your Phone, not only from a python script.

btw. guitarix does that since years now, and a lot of projects use sockets to control guitarix from a arduino board for example, or control guitarix running on a RPI.

Re: Using MIDI for RPC

Posted: Tue Apr 16, 2019 11:40 am
by Basslint
tramp wrote:Why do you want that?
First point is, you need to abuse a protocol to do so, this abuse must be supported by the application you want to serve by this.
Much easier is a socket to use, which could do all that, without abusing a protocol. A (rpc) socket could as well be used across networks, so you could control the app in question from a other PC or tablet or even from your Phone, not only from a python script.

btw. guitarix does that since years now, and a lot of projects use sockets to control guitarix from a arduino board for example, or control guitarix running on a RPI.
Well, you are right, I guess I was thinking about using already established things like JACK to make this kind of communication more straightforward for non-techies as well...just plug two MIDI ports and let programs do the talking, something like that.

Re: Using MIDI for RPC

Posted: Tue Apr 16, 2019 11:49 am
by tavasti
I think scope is too narrow. Pretty logical extension of this idea would be TCP/IP over MIDI. And I would not be amazed if someone would have implemented that.

Re: Using MIDI for RPC

Posted: Tue Apr 16, 2019 12:13 pm
by Basslint
tavasti wrote:I think scope is too narrow. Pretty logical extension of this idea would be TCP/IP over MIDI. And I would not be amazed if someone would have implemented that.
http://www.halfbakery.com/idea/TCP_2fIP_20over_20MIDI

It looks like someone thought about it but I couldn't find any implementation...this could also open the road for OSC over MIDI I think (even if it uses UDP)!

Re: Using MIDI for RPC

Posted: Tue Apr 16, 2019 12:18 pm
by j_e_f_f_g
Basslint wrote:Is there a way to use MIDI to send arbitrary data?
Yes. You put the data inside a "System Exclusive" MIDI message. This message starts with the hex byte F0 and ends with the hex byte F7. In between these two bytes can be any number of bytes, for any purpose. But the data bytes must be 7-bit (ie, only values 0 to 127). So if you need values 128 to 255, you'll have to "bit pack" the data when it is sent, and unpack when received.

To make sure you don't interfere with System Exclusive messages already used by various MIDI equipment, it's recommended that the first (one to three) data bytes be a "manufacturer's ID" as registered with MIDI Manufacturer's Association (MMA). For example, Microsoft's ID is hex 00 00 41. So Microsoft sysex messages start with the 4 bytes:

Code: Select all

F0 00 00 41
You can freely use the ID of 7d for testing purposes. But you shouldn't use it for production code.

If you have a MIDI-related question, I'm the guy you want to talk to.

Attached to this post is a zip file containing some tutorials I've written about MIDI specs.

P.S, Although Open Sound Control (OSC) supports sending most MIDI messages, it doesn't support sending MIDI System Exclusive.