Set divisor of a / object from js
Hi, is there a way to do this from js? Think I need to send a message directly to inlet 2 but can't remember/figure out if this is possible from js?
Thx
There are a handful of different ways to do this with js:
send the object
in1 [val]
(for an integer object) orft1 [val]
(for a float object) message (easiest)recreate the object with the desired divisor value (slightly less easy)
invisibly create a message box with the desired divisor value, connect it to the right inlet of the div object and bang it out, then delete the temp object (most annoying, but old school)
function setdiv(v) {
var obj = this.patcher.getnamed("div");
obj.message("ft1", v); // or obj.message("in1", v);
}
function setdiv2(v) {
var obj = this.patcher.getnamed("div");
// uses some mystery 'newex' sauce
this.patcher.message("script", "replace", "div", "newex", 0, 0, 0, 12.5, "/", v);
}
function setdiv3(v) {
this.patcher.newdefault(300, 400, "message", "@text", v, "@hidden", 1, "@varname", "tmpmsg");
this.patcher.message("script", "connect", "tmpmsg", 0, "div", 1);
var tmpobj = this.patcher.getnamed("tmpmsg");
tmpobj.message("bang");
this.patcher.remove(tmpobj);
}
thx ben - very helpful. It was the first form I'd used in the past, just couldn't remember the format.
Cheers