Proposition: solution for sysex...SOLVED!!!

Learn about building and using Max for Live devices.
3dot...
Posts: 9996
Joined: Tue Feb 20, 2007 11:10 pm

Re: Proposition: solution for sysex

Post by 3dot... » Fri Mar 19, 2010 2:21 pm

ST8 wrote:@hofmann2k

that is totally doable, i'll try and sort out a test script over the weekend that just pipes raw midi too and from a udp socket,
YES PLEASE !!! 8O
wow this would really help me out right now..
Image

hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: Proposition: solution for sysex

Post by hoffman2k » Fri Mar 19, 2010 2:39 pm

Sweet! :D

The way I understand it, with UDP we bypass Max's scheduler. Depending on how long the piping in python takes, that should be the only latency.

ST8
Posts: 259
Joined: Mon Jan 26, 2009 12:55 pm

Re: Proposition: solution for sysex

Post by ST8 » Fri Mar 19, 2010 2:43 pm

Latency will be of the order of 60-100ms im afraid, the remote scripts are not designed to be strictly timed. Theres no threading (threads are killed or knocked to 60ms refresh), and no select module, so your stuck with processing incoming data in a 100ms refresh function (or 60ms if you use the callback for the current song time).

I'm not sure what sysex is used for on a lot of synths and the likes, do you need strict timing? 60ms should be fine for updating displays and the likes though.

hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: Proposition: solution for sysex

Post by hoffman2k » Fri Mar 19, 2010 2:54 pm

ST8 wrote:Latency will be of the order of 60-100ms im afraid, the remote scripts are not designed to be strictly timed. Theres no threading (threads are killed or knocked to 60ms refresh), and no select module, so your stuck with processing incoming data in a 100ms refresh function.

I'm not sure what sysex is used for on a lot of synths and the likes, do you need strict timing? 60ms should be fine for updating displays and the likes though.
Honestly, its not for me personally. People using synths usually have CC controls for more immediate stuff. The sysex is useful for tweaking rare parameters which depending on their sound require real-time or not.

But this isn't just sysex, right? If everything is passed, people can use multiple channels of MIDI. The entire midi spec unfiltered.
I have a BCR application I built for Max runtime, to port it to M4L, I'd require 16 channels of CC's and a 100+ ms latency would be acceptable.

But now I'm wondering. Does this mean ALL remote MIDI scripts are having this same latency? For example with every automapped controller controlling a Macro.

ST8
Posts: 259
Joined: Mon Jan 26, 2009 12:55 pm

Re: Proposition: solution for sysex

Post by ST8 » Fri Mar 19, 2010 3:02 pm

Yer your right this applies to all midi, certainly not just to sysex, so you should be able to talk to any channel, its just a nibble on the first byte of midi data.

For receiving midi data (ie from controller -> Midi Script) there is a specific callback, but i think this is still limited to around 60ms.

I think note data is passed directly to ableton and not interfered with so timing is strict, however CCs do go into a midi remote scripts. So yes my understanding is that automapped parameters do respond on around a 60ms timescale.

PS: Also bear in mind that you'll loose any automap functions as i dont think you can map the same port to more than one midi remote script

flowdesigner
Posts: 930
Joined: Sun Dec 21, 2008 5:58 am

Re: Proposition: solution for sysex

Post by flowdesigner » Fri Mar 19, 2010 3:33 pm

So, that will open the door for this :D

http://www.youtube.com/watch?v=EgGn85rolJE

hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: Proposition: solution for sysex

Post by hoffman2k » Fri Mar 19, 2010 3:33 pm

ST8 wrote:Yer your right this applies to all midi, certainly not just to sysex, so you should be able to talk to any channel, its just a nibble on the first byte of midi data.

For receiving midi data (ie from controller -> Midi Script) there is a specific callback, but i think this is still limited to around 60ms.

I think note data is passed directly to ableton and not interfered with so timing is strict, however CCs do go into a midi remote scripts. So yes my understanding is that automapped parameters do respond on around a 60ms timescale.

PS: Also bear in mind that you'll loose any automap functions as i dont think you can map the same port to more than one midi remote script
Ah. Thanks for the explanations. I'm not too worried about losing automap, I made my own. Theoretically with sample accuracy, but there's always the delay of incoming MIDI.

This all sounds very acceptable compared to piping it from a 3rd party source and everything you need could be stored with the Live Set. No more looking for this and that when loading old projects. Its all there along with the version used at that time.
This would do nicely until Ableton gets rid of the limits on track input.

As far as I am aware, there's only one mystery left in the API. The red ring and offset calls/functions. Anybody got the code for the SessionComponent? I believe that is where those functions lie.

Hanz_Petrov
Posts: 119
Joined: Sat Feb 06, 2010 2:39 pm
Contact:

Re: Proposition: solution for sysex

Post by Hanz_Petrov » Fri Mar 19, 2010 4:02 pm

hoffman2k wrote: As far as I am aware, there's only one mystery left in the API. The red ring and offset calls/functions. Anybody got the code for the SessionComponent? I believe that is where those functions lie.
My ProjectX example script shows how to manipulate the "red box". I use a Framework SessionComponent with mappings for left & right and up & down, and also override _on_selected_track_changed to automatically set the box focus to the currently selected track. The required code is fully commented at my site.

Hanz
http://remotescripts.blogspot.com/ - an introduction to the Framework classes

Hanz_Petrov
Posts: 119
Joined: Sat Feb 06, 2010 2:39 pm
Contact:

Re: Proposition: solution for sysex

Post by Hanz_Petrov » Fri Mar 19, 2010 4:21 pm

ST8 wrote:For receiving midi data (ie from controller -> Midi Script) there is a specific callback, but i think this is still limited to around 60ms.

I think note data is passed directly to ableton and not interfered with so timing is strict, however CCs do go into a midi remote scripts. So yes my understanding is that automapped parameters do respond on around a 60ms timescale.
Hi ST8 :)

The newer scripts seem to use a callback to refresh the hardware state at an interval of 5 ticks:

Code: Select all

    def refresh_state(self):
        ControlSurface.refresh_state(self)
        self.schedule_message(5, self._update_hardware)
and from ControlSurface:

Code: Select all

    def schedule_message(self, delay_in_ticks, callback, parameter = None):
        """ Schedule a callback to be called after a specified time """
        assert (delay_in_ticks > 0)
        assert (callback != None)
        assert (dir(callback).count('im_func') is 1)
        self._scheduled_messages.append({'Message': callback,
         'Delay': delay_in_ticks,
         'Parameter': parameter})
If a MIDI tick is 10 milliseconds, then the default refresh interval is 50ms, although it might be possible to feed the function with a lower delay_in_ticks.

Hanz
http://remotescripts.blogspot.com/ - an introduction to the Framework classes

ST8
Posts: 259
Joined: Mon Jan 26, 2009 12:55 pm

Re: Proposition: solution for sysex

Post by ST8 » Fri Mar 19, 2010 4:52 pm

Unfortunately those are not real midi ticks, if you look where the scheduled messages are actually processed its in update_display, which is only once every 100ms, therefore 5 ticks in remote script land = 500ms!

http://hanzoffsystems.tech.officelive.c ... te_display

The red ring is available from python. We could maybe double up the sysex handler with a red ring handler too? Maybe an illegal midi message could move the box around or something?

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: Proposition: solution for sysex

Post by amounra93 » Fri Mar 19, 2010 5:41 pm

@hoffman2k

Ahhhhh...see, I've been trying to get MIDI through directly from a [live.object], without success. I spent a long time last night messing with different portions of the python scripts with no luck. A script that passes MIDI to UDP would work well for me, also, now that I think about it. I, also, am mainly seeking compartmentability.

@ST8

You rock :)
http://www.aumhaa.com for Monomod and other m4l goodies.

ST8
Posts: 259
Joined: Mon Jan 26, 2009 12:55 pm

Re: Proposition: solution for sysex

Post by ST8 » Sat Mar 20, 2010 8:32 pm

Ok heres an initial draft, not tested it fully. This listens on port 5000 for raw midi data. udpsend send 12 134 151 etc in pure data (i think its the same in maxmsp?). It'll also return any ccs from your controller on port 5001 if set to receive midi too.

http://monome.q3f.org/changeset/latest/ ... format=zip

Drop the sysex folder into your MIDI Remote Scripts folder
on mac: /Live x.x.x/Live.app/Contents/App-Resources/MIDI Remote Scripts
on win: c:\progs\ableton\live x.x.x\Resources\MIDI Remote Scripts

You'll also probably need python 2.5.1 installed. If you're on osx 10.5.8 its already installed, if you're on 10.6 you need to install.

If you send a message of length 5 bytes starting with a 0, it'll update the selected region in live.
ie udpsend 0 0 0 3 4 = x offset, y offset, width, height
Last edited by ST8 on Sat Mar 20, 2010 9:03 pm, edited 1 time in total.

hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: Proposition: solution for sysex

Post by hoffman2k » Sat Mar 20, 2010 8:58 pm

ST8 wrote:Ok heres an initial draft, not tested it fully. This listens on port 5000 for raw midi data. udpsend send 12 134 151 etc in pure data (i think its the same in maxmsp?). It'll also return any ccs from your controller on port 5001 if set to receive midi too.

http://monome.q3f.org/changeset/latest/ ... format=zip

Drop the sysex folder into your MIDI Remote Scripts folder
on mac: /Live x.x.x/Live.app/Contents/App-Resources/MIDI Remote Scripts
on win: c:\progs\ableton\live x.x.x\Resources\MIDI Remote Scripts

You'll also probably need python 2.5.1 installed. If you're on osx 10.5.8 its already installed, if you're on 10.6 you need to install.

If you send a message of length 5 bytes starting with a 0, it'll update the selected region in live.
ie udpsend 0 0 0 3 4 = x offset, y offset, width, height
Sweet :)

You sure this is the right file though? Looks like the entire LiveControl package.


hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: Proposition: solution for sysex

Post by hoffman2k » Sat Mar 20, 2010 9:17 pm

It definitely responds to incoming CC's. But I get the following error instead of data:

udpreceive: OSC packet size (3) not a multiple of 4 bytes: dropping

No response to notes and program changes, but I may not be testing it properly. I'm just sending from some max helpfiles like ctlout and pgmout. Quick tests..

Post Reply