Best way to integrate custom JS code and external libraries?

Hello,

I want to integrate a module with custom graphic interface and behaviour programmed in JS, probably with Planck.js, Matter.js or P5.js.

What is the way to go: a Frame module or a Custom module? Also, do I have to run a seaparate HTML server to load the JS?

There's is no convenient way to do it without editing the sources and building you own version of o-s-c.

A frame widget would allow you displaying another webpage (the value can be a path to an html file, it doesn't necessarily have to be served by its own http server). This webpage will not be able to interract with other widgets though unless you manage to make it send osc messages to the server.

Thank you Jean-Emmanuel. One additional question: should the path to the HTML page be absolute or relative to the O-S-C app? Maybe you have an example?

Also, what is the compatibility level/standard with JS? I could run some Rapier or Matter.js online examples but not P5.js examples.

Absolute path or relative to the session file.

Also, what is the compatibility level/standard with JS? I could run some Rapier or Matter.js online examples but not P5.js examples.

It's as compatible as a browser can be although the frame may add some limitations, check the console (f12) for errors if it doesn't work. You should test the webpage directly in a browser before displaying it in a frame too.

1 Like

To chime in on this, I'm building a sequencer, and since all the code is running client side, and I'm running on an M1 iPad that is only running O-S-C, I'd like to try integrating tensor flow and have the sequencer make some AI beats. Could you walk us through how to build from source?

For the record I don't think implementing this kind of thing on the client side is a good idea, o-s-c aims to provide a remote control with some scripting conveniences, but anything time-critical is considered out of scope and it is strongly assumed that these things are handled by other softwares. You're of course free to implement that in your build but I should warn you that such things are extremely unlikely to get implemented in the official build.

The sequencer isn't time critical. It sends the timing data over to Ableton, and creates clips with the specified timing data...so Ableton's clock is running everything. It works pretty darn well! Thanks for the info Jean. You are the man.