Using MIDI for RPC

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
Basslint
Established Member
Posts: 1511
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy
Has thanked: 382 times
Been thanked: 298 times

Using MIDI for RPC

Post 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?
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]

Please donate time (even bug reports) or money to libre software 🎁

Jam on openSUSE + GeekosDAW!
tramp
Established Member
Posts: 2335
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 9 times
Been thanked: 454 times

Re: Using MIDI for RPC

Post 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.
On the road again.
Basslint
Established Member
Posts: 1511
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy
Has thanked: 382 times
Been thanked: 298 times

Re: Using MIDI for RPC

Post 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.
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]

Please donate time (even bug reports) or money to libre software 🎁

Jam on openSUSE + GeekosDAW!
tavasti
Established Member
Posts: 2047
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 369 times
Been thanked: 208 times
Contact:

Re: Using MIDI for RPC

Post 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.

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

Basslint
Established Member
Posts: 1511
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy
Has thanked: 382 times
Been thanked: 298 times

Re: Using MIDI for RPC

Post 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)!
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]

Please donate time (even bug reports) or money to libre software 🎁

Jam on openSUSE + GeekosDAW!
j_e_f_f_g
Established Member
Posts: 2032
Joined: Fri Aug 10, 2012 10:48 pm
Been thanked: 357 times

Re: Using MIDI for RPC

Post 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.
Attachments
midispec.zip
(98.57 KiB) Downloaded 81 times

Author of BackupBand at https://sourceforge.net/projects/backupband/files/
My fans show their support by mentioning my name in their signature.

Post Reply