M4L & MXJ

Learn about building and using Max for Live devices.
Post Reply
JoeM
Posts: 14
Joined: Thu Dec 20, 2007 6:55 am
Contact:

M4L & MXJ

Post by JoeM » Fri Feb 26, 2010 3:38 am

I'm still a beginner when it comes to Max. I wrote a basic patch for my Korg padKontrol using mostly js last summer. I'm working on a complete patch in M4L to turn my padKontrol into a full fledged Live controller.
I'm a veteran programmer and would be 100 times more productive writing everything in code. Max is basically only used for processing sysex data and plugging into Live at this point. The main logic is much better suited for a full programming language. I used the OO js framework MooTools in my last patch successfully. The problem with Js is there is no concept of includes and my source file quickly got way out of hand for a basic patch, and I anticipate this next one to be much more advanced by several orders of magnitude.

Is it possible to access the M4L api via MXJ? Since there is a JS interfect, if MXJ doesn't work, would it be feasible to send messages to a simple JS file for interacting with MXJ, or perhaps a barrage of Live.API objects/observers hooked into MXJ input & output?
Live 8 (boxed suite) - 17" MacBook Pro - Remote SL 37 - Audio DJ 8 - Korg padKontrol -
Hooked up as an effect device and live instrument for Traktor

JoeM
Posts: 14
Joined: Thu Dec 20, 2007 6:55 am
Contact:

Re: M4L & MXJ

Post by JoeM » Fri Feb 26, 2010 4:55 am

To follow up, I've come up with a stupidly easy way to send messages to Live from Java.

I basically create several different outlets in my main class and give them easy to remember labels using static ints. (I remember Java get enum but they're nothing like my beloved C ones so this works for me)

private static final int LiveSet_Outlet = 2;
private static final int LiveApp_Outlet = 3;

So my second MXJ object outlet will connect directly to a live.object that has its path set to live_set, the next with live_app etc.

Then simply call something like,

outlet(LiveSet_Outlet, "call", "start_playing");

and presto, the set starts to play.

I have a feeling getting data in from Live won't be nearly as easy though without access to a Live object with call back support.
Live 8 (boxed suite) - 17" MacBook Pro - Remote SL 37 - Audio DJ 8 - Korg padKontrol -
Hooked up as an effect device and live instrument for Traktor

JoeM
Posts: 14
Joined: Thu Dec 20, 2007 6:55 am
Contact:

Re: M4L & MXJ

Post by JoeM » Fri Feb 26, 2010 5:48 am

And yet another advancement,

You can progamatically call any Live object without using outlets. Here's a simple example where I have a [live.object ] with the script name of "live_set". It's live.path is set on load to 'live_set'.

MaxPatcher myPatch = getParentPatcher();
MaxBox liveAPI_set = myPatch.getNamedBox("live_set");

liveAPI_set.send("call", Atom.newAtom( new String[]{"start_playing"}) );

Unfortunately this is as far as I think the MXJ object can go.

I had an idea for getting data out of a Live.object by creating a bunch of inlets and having a master Live API object that other classes would call with pointers to call back functions. This API wrapper class would make calls to external live.objects and dynamically in code hook their outputs to an array of available inputs. Picture an old school telephone operator switch, where you would move cables between available inputs to patch calls together. Same kind of idea. This would probably be overly complex and wouldn't work well for things such as path observers. I've decided to go the ugly large JS route for now. :|
Live 8 (boxed suite) - 17" MacBook Pro - Remote SL 37 - Audio DJ 8 - Korg padKontrol -
Hooked up as an effect device and live instrument for Traktor

cturner
Posts: 40
Joined: Sun Dec 06, 2009 4:09 pm
Location: GWB

Re: M4L & MXJ

Post by cturner » Fri Feb 26, 2010 11:53 am

JoeM wrote:The problem with Js is there is no concept of includes and my source file quickly got way out of hand for a basic patch, and I anticipate this next one to be much more advanced by several orders of magnitude.
I haven't worked with them, but there's a bunch of activity with module loaders for Javascript:
http://groups.google.com/group/prototyp ... 129cd4ae3#

But I'd suggest you look at our very own Tom Swirly's use of Make in this context, which is dead simple and does the trick:
http://forum.ableton.com/viewtopic.php? ... 8#p1061878

HTH, Charles

steff3
Posts: 330
Joined: Sat Jul 10, 2004 10:16 am

Re: M4L & MXJ

Post by steff3 » Fri Feb 26, 2010 2:25 pm

[quote="JoeM"]
Is it possible to access the M4L api via MXJ? Since there is a JS interfect, if MXJ doesn't work, would it be feasible to send messages to a simple JS file for interacting with MXJ, or perhaps a barrage of Live.API objects/observers hooked into MXJ input & output?[/quote]

Well, I asked about that during public beta over at Cycling and the reply was that it is not and unlikely that it will happen ....

best

JoeM
Posts: 14
Joined: Thu Dec 20, 2007 6:55 am
Contact:

Re: M4L & MXJ

Post by JoeM » Fri Feb 26, 2010 4:57 pm

cturner wrote:
JoeM wrote:The problem with Js is there is no concept of includes and my source file quickly got way out of hand for a basic patch, and I anticipate this next one to be much more advanced by several orders of magnitude.
But I'd suggest you look at our very own Tom Swirly's use of Make in this context, which is dead simple and does the trick:
http://forum.ableton.com/viewtopic.php? ... 8#p1061878
Ha, stroke of genius. It's always the simple method you overlook. I actually remember using MAKE this way a long long time ago. I should know better considering I've even worked on a translator for XCode project files to GNU Makefiles :oops:

This will work great in combination with some OO JS frameworks. I've had great success using Mootools to create a midi controller for Traktor through Max already. The engine seems fast enough to do a fair amount of object references in real time. I was using it as a drum machine for cue points similar to their new promo video for Maschine.

If I come up with a nice OO JS class for the Live API I'll be more than happy to share it here. Pretty snowed in this weekend in NYC.
Live 8 (boxed suite) - 17" MacBook Pro - Remote SL 37 - Audio DJ 8 - Korg padKontrol -
Hooked up as an effect device and live instrument for Traktor

cturner
Posts: 40
Joined: Sun Dec 06, 2009 4:09 pm
Location: GWB

Re: M4L & MXJ

Post by cturner » Fri Feb 26, 2010 5:34 pm

JoeM wrote:Pretty snowed in this weekend in NYC.
Yup, 16"+ in Central Park. Pretty Fantastic!

stefan-tiedje
Posts: 219
Joined: Thu Sep 17, 2009 3:50 pm
Location: Berlin

Re: M4L & MXJ

Post by stefan-tiedje » Fri Mar 05, 2010 11:34 am

JoeM wrote:I'm a veteran programmer and would be 100 times more productive writing everything in code.
I am also a veteran programmer, but switched to Max almost 20 years ago... I never ever wanted to turn back - its simply a different way of thinking...
But as you are seemingly very familiar with lines of coding in C, you could create some useful externals aimed at M4L. And as you seem to miss OO features you should definitely look at the oo externals made by Mattjis Kneppers and John Pitcairn for Mac:
http://cycling74.com/download/Share/Mat ... 41_mac.zip
for PC:
http://cycling74.com/download/Share/Mat ... 41_win.zip
There is also an interview with Mattjis on the cycling site:
http://cycling74.com/2008/10/28/an-inte ... -kneppers/
His website is a bit strange to navigate...
http://www.arttech.nl/

Stefan
Les Ondes Mémorielles-----x---
--____-----------|----------|----
--(_|_ ----|\-----|-----()--------
-- _|_)----|-----()---------------
----------()----------TJ Shredder
http://tjshredder.wordpress.com/

maxforlive
Posts: 70
Joined: Thu Nov 05, 2009 3:30 pm

Re: M4L & MXJ

Post by maxforlive » Fri Mar 05, 2010 7:27 pm

stefan-tiedje wrote:
JoeM wrote:I'm a veteran programmer and would be 100 times more productive writing everything in code.
I am also a veteran programmer, but switched to Max almost 20 years ago... I never ever wanted to turn back - its simply a different way of thinking...
But as you are seemingly very familiar with lines of coding in C, you could create some useful externals aimed at M4L. And as you seem to miss OO features you should definitely look at the oo externals made by Mattjis Kneppers and John Pitcairn for Mac:
http://cycling74.com/download/Share/Mat ... 41_mac.zip
for PC:
http://cycling74.com/download/Share/Mat ... 41_win.zip
There is also an interview with Mattjis on the cycling site:
http://cycling74.com/2008/10/28/an-inte ... -kneppers/
His website is a bit strange to navigate...
http://www.arttech.nl/

Stefan


Do you ever feel the need for doing stuff in csoound or supercollider or similar?

stefan-tiedje
Posts: 219
Joined: Thu Sep 17, 2009 3:50 pm
Location: Berlin

Re: M4L & MXJ

Post by stefan-tiedje » Thu Mar 11, 2010 9:55 pm

Never - well I am sort of curious, but whenever I get to lines of code I think how much easier Max seems. But I am aware that its is a different kind of thinking which would lead to different ways of doing the same. And it would lead to different results as well... In the not so far past I used javascript in Max to access information not available elsewhere (position of bpatchers for example) and Java for some in depth fft processing, basically a port from existing Mathlab code...
To find out the benefits of Supercollider, I would need to spend more time with it...

Stefan
Les Ondes Mémorielles-----x---
--____-----------|----------|----
--(_|_ ----|\-----|-----()--------
-- _|_)----|-----()---------------
----------()----------TJ Shredder
http://tjshredder.wordpress.com/

Post Reply