zynthian / zynthian-issue-tracking

Centralized Issue Tracking for Zynthian Project
https://github.com/orgs/zynthian/projects/1
11 stars 3 forks source link

Add OSC to MIDI #15

Closed riban-bw closed 5 years ago

riban-bw commented 5 years ago

OSC is a protocol with similarities to MIDI and is used in various implementations to pass MIDI data such as note on/off, continuous controller, etc. It may be advantageous to implement an OSC to MIDI bridge which would allow an OSC sending device to control zynthian like a MIDI controller.

An OSC path would need to be implemented, e.g. /midi//. OSC server would need to run in real-time - it currently sits inside the zyncoder_thread_task which is prone to delays due to processing zyncoder, zynmidi, etc. and the 40ms loop delay and occasional 300ms loop delay. (It may be appropriate to implement real-time OSC within a C library if Python proves too slow.) Supported OSC paths could feed zynmidirouter. Unsupported paths should be ignored. MIDI to OSC bridge may also be desirable with its input being fed from the output of zynmidirouter. This may require more consideration (due to the current MIDI routing design) so may need to be subject to a follow-up feature request.)

It may be possible to use an external MIDI to OSC bridge application (similar to a2jmidid) such as OSC2MIDI. This has the advantage of possibly requiring less up-front development and a separate if code (Unix style) but may prove to be insufficiently configurable or integration may not be tight enough. (For the proposed requirement this may prove perfectly suitable - I have not looked at this in any detail, but can do!)

There are very few hardware instruments that currently support OSC (if any). Zynthian could be a trail blazer.

jofemodo commented 5 years ago

Zynthian currently includes support for OSC-MIDI with the TouchOSC2MIDI library that can be enabled from the Zynthian UI. I would like to improve this support, but currently little or any feedback has been received, so i suppose that interest is low and we should allocate our limited resources in other areas. Anyway, i stay open ;-)

jofemodo commented 5 years ago

I think the real problem here is the lack of a official or "de-facto" standard for passing MIDI over OSC. See that thread:

https://stackoverflow.com/questions/28913458/existing-standards-for-passing-midi-via-osc

We've already implemented one of these protocols (TouchOSC2MIDI), that is quite popular in android apps. Of course i'm open to integrate any other OSC protocol with a decent free software implementation. Let's do some research ...

riban-bw commented 5 years ago

Yep! I looked for a standard and there have been a few efforts but nothing really suitable. I got OSC2MIDI working quite easily so that could be an option. (Simple mod to autoroute to accept the extra jack midi input.) I also got touchosc2midi working with OSC message format:

UDP port: 12101
OSC path: /midi
OSC message: 'm', (<data1>,<data0>,<status>,<osc port>)

e.g. Note 60 on channel 1:

liblo.send(('zynthian.local', 12101), "/midi", ('m', (100,60,0x90,0)))

I guess with this info we can implement OSC MIDI in its rawest form without any extra effort. I had to figure this format out empirically. It would be good to provide information to others who want to interface via OSC.

riban-bw commented 5 years ago

I suggest we add the TouchOSC MIDI support format to the wiki then close this issue. I looked at the wiki and thought this could go on a page linked from "TouchOSC Bridge" on the Features page. I cannot create wiki pages so cannot do this myself.

jofemodo commented 5 years ago

It's strange. You should be able to create "nodes" (pages) on the wiki. I think that no special privileges are needed. I will re-check.

jofemodo commented 5 years ago

Group | Rights

(all) | Create discussion pages (createtalk) Create pages (which are not discussion pages) (createpage) Edit your own preferences (editmyoptions) Edit your own private data (e.g. email address, real name) (editmyprivateinfo) Edit your own user CSS files (editmyusercss) Edit your own user JavaScript files (editmyuserjs) Edit your own watchlist. Note some actions will still add pages even without this right. (editmywatchlist) Read pages (read) Use of the write API (writeapi) View your own private data (e.g. email address, real name) (viewmyprivateinfo) View your own watchlist (viewmywatchlist)

jofemodo commented 5 years ago

Definitely, you should be able to create pages ;-)

riban-bw commented 5 years ago

Where is the button to add a node / page? I do not see a way to do this.

riban-bw commented 5 years ago

I have added a section to Accessing_Zynthian_from_your_computer wiki page and linked from Zynthian_Features. I am happy we have OSC implemented. It isn't the ideal solution I envisaged but it provides the same functionality and a platform from which to build. I will close this issue.