Using MIDI for RPC

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

Basslint
Established Member
Posts: 197
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy

Using MIDI for RPC

Postby Basslint » Sat Apr 13, 2019 5:25 pm

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?
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

tramp
Established Member
Posts: 1455
Joined: Mon Jul 01, 2013 8:13 am

Re: Using MIDI for RPC

Postby tramp » Sun Apr 14, 2019 4:44 pm

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.
On the road again.

Basslint
Established Member
Posts: 197
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy

Re: Using MIDI for RPC

Postby Basslint » Tue Apr 16, 2019 11:40 am

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.
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

tavasti
Established Member
Posts: 860
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Contact:

Re: Using MIDI for RPC

Postby tavasti » Tue Apr 16, 2019 11:49 am

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.
Linux veteran & Novice musician

Hear my music at https://audiu.net/users/tawaste

Basslint
Established Member
Posts: 197
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy

Re: Using MIDI for RPC

Postby Basslint » Tue Apr 16, 2019 12:13 pm

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)!
Last edited by Basslint on Tue Apr 16, 2019 12:28 pm, edited 1 time in total.
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

j_e_f_f_g
Established Member
Posts: 1055
Joined: Fri Aug 10, 2012 10:48 pm

Re: Using MIDI for RPC

Postby j_e_f_f_g » Tue Apr 16, 2019 12:18 pm

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.
You do not have the required permissions to view the files attached to this post.


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 2 guests