processing.js in Max

freepoulite's icon

Hello

No news about use processing.js inside Max
Is it possible or not?
It would be amazing!

Michael Sperone's icon

I've been thinking about this... would it be possible to export to javascript and then just use [js]?

freepoulite's icon

it would be great to use directly [jsui]
I will try this morning, if it works i will share an exemple

Michael Sperone's icon

I got this to work. It uses [jweb] so I don't know what kind of output/input you can get from this way of doing it.

But at least I got something to work :)

4652.processingTest.zip
zip
deligut's icon

I tried your patch on a windows computer without any luck. Any idea why this is? I can open the html document separately. Jweb finds the file htmlProcessing.html, it just does not display anything.

Michael Sperone's icon

I just tried downloading and opening what I posted and it works here.

It should work on windows, I didn't use an external and processing.js is the same for all platforms.
Maybe try your own processing sketch? It didn't work for the first sketch I tried to run, and I never found out why.
You can just modify the html file (which by the way contains an extra line I commented out because I originally copied the html from the processingjs.org homepage - in case you were wondering what that was) to have your file name instead (and make sure your sketch is in the folder with the max patch).

If another sketch doesn't work, then I might suggest asking on the processingjs forum about javascript compatibility. maybe?

Michael Sperone's icon

This link might prove to be useful... also if you scroll up a bit there's a heading called "Pre-compiling Processing code to JavaScript" which is what I'm trying to do now.

Michael Sperone's icon

Looks like I'm the only one interested in this ;) hehe

BUT, I just figured out what the deal is with libpd.... and it's not Max, but PD... and it's not processing in PD, but PD in processing
I know it's a little off topic, but I thought it may be useful to know about

This website was most useful to getting it to all work:
http://robertesler.com/libpd-with-processing/

-Mike

devslashnull's icon

Hi, I know this has sat idle for a while, but I am wondering if you pushed on this any further? I am trying to simplify a set up that includes a Processing sketch that sends video data out a serial port by pulling that data via syphon from wherever... I'd prefer if I could somehow wrap that part of the system (the processing sketch) up into some javascript and just run it inside my Max patch, skip the syphoneing and just send my jitter matrix right into the js...

Anthony Palomba's icon

I have worked on this pretty extensively. I am currently working on a porting library for processing sketches using mgraphics.

The basic idea is you take your processing sketch, convert it to java script (which is pretty easy after you have done it a few times) then run the sketch. It should appear and behave as it does in processing.

Although I have not ported over the full precessing API, I have enough here to do some interesting stuff. I have attached what I have so far. Feel free to give it a spin and let me know what you think.

Please put processinglib.js in your Max jsextentions directory, then restart max before running the sketch.

processing-sketches.zip
zip
Floating Point's icon

hey Anthony this looks really interesting but can't seem to get it working:

loading P_2_2_3_02
js: processinglib.js: Javascript ReferenceError: mgfx is not defined, line 226
js: processinglib.js: Javascript ReferenceError: mgfx is not defined, line 226
js: error calling function setup [P_2_2_3_02-2.js]
jit.pwindow: jit.pwindow: object u905000363 is not a valid matrix
js: P_2_2_3_02-2.js: Javascript TypeError: plib.draw is not a function, line 93
js: error calling function bang [P_2_2_3_02-2.js]

Anthony Palomba's icon

Well that is strange...

What version of Max are you running? Are you Windows or OSX?

Floating Point's icon

here's the details; the js object instantiates and I can see the code when it is sent the open message. The js extension is where you specified...
OSX 10.6.8, {
    "version" : "Version 6.1.4 (22b50b3)",
    "platform" : "mac",
    "arch" : "x86",
    "osversion" : "Mac OS X Version 10.6.8 x86_64",
    "samplerate" : 44100,
    "iovs" : 1024,
    "sigvs" : 64,
    "scheduler_in_audio_interrupt" : "off",
    "audio_drivername" : "Core Audio",
    "audio_driver_subname" : "",
    "eventinterval" : 2,
    "overdrive" : "off",
    "mixerparallel" : "on",
    "mixercrossfade" : 1,
    "mixerlatency" : 30.0,
    "mixerramptime" : 10.0
}

Anthony Palomba's icon

Okay, I sorted out the problem. I sent the wrong version of processingLib.js
I have attached a new version. Please put it in your jsextension directory and
restart Max. Then start the sketch and let me know if it works.

processinglib.js
js
Floating Point's icon

Thanks Anthony, your example patch works on my machine now. Very cool. I'm assuming the empty functions like

function smooth()
{

}

are processing functions that have not yet been remapped to mgraphics?

Anthony Palomba's icon

Yes, that is correct. I believe smooth() turns on anti-aliasing in processing. I did not put any implementation there because anti-aliasing is always on in Jitter. I also have it there so that porting sketches will be easier.