Intercepting object's output with Javascript: possible?
Hello,
Is it possible to intercept an object's output with Javascript? It's easy to get data from an object in JS when there's a matching attribute. But what when the object outputs a message, especially a bang (when a sound has been played for instance) ? So far I haven't found an alternative to sending a cable back to my V8 object but isn't there an easier way? I ask especially because the object sending the information is created by script, so the connection should be rebuilt at each launch of the script.
AFAIK this is not possible.
It may have a technical reasons. Crossing the “language frontier” to JS is relatively slow. Intercepting messages via JS would mean, that potentially every message in a Max patch would have to be passed to the JS engine. Also JS is limited to to the low priority thread….
But maybe/hopefully someone can prove me wrong:)
I would agree, this functionaloty is not available. The JS API could perhaps provide an OutletListener() class or something, if enough users demonstrated in front of the C74-office…
Meanwhile — and understanding that patchcords with v8 always seem redundant ;) — have you considered changing another object's attribute whenever an event passes and observing that one in JS? even a toggle which goes on/off on receiving a bang could perhaps help. But then, I get it, why do such a thing when one can just connect patchcords in the end…
I mean, if you have toggles (e.g.) attached anyways, just allocate them all to the same scripting-name family and automatically observe those in the code. applydeep() and stuff…
? meanwhile.
This is an interesting idea.