problem: connecting to existing objects via scripting

Jan 14, 2012 at 5:05pm

problem: connecting to existing objects via scripting


I am trying to connect already existing objects to new generated ones via java-script and it fails.
What I was trying to do for that:

1.) give the existing object a scripting name (e.g.: monitorSndPos)
2.) make a maxobj variable for scripting:
var monitorSndPos = this.patcher.getnamed(“monitorSndPos”);
3.) after generating the new object, connect the existing object to the new one:
this.patcher.connect(monitorSndPos, 0, theencode, 0);

it doesn’t work.

when I add the following line into the java-script code, then the desired and the new connection is made:
this.patcher.connect(monitorSpeakerPos, 0, monitorSndPos, 0);
(but this is just a nonsense connection between two already existing objects).
when I now delete this new line again, and execute everything, than it works how it is supposed to be.
It seems to me that there is a problem at the beginning with the initializing of the existing objects, but I can’t figure it out. This cannot be a long-term solution, especially when you want to use this script in an external to be usable for others. Maybe someone has an idea?


Jan 15, 2012 at 1:11am

I’ve never had this problem with patcher scripting. I’d be happy to help you look in to the problem though. If you could try to replicate it with the fewest objects/smallest js code possible and attach the files here I’ll take a look if you’d like.

Jan 15, 2012 at 9:03pm

ok, the problem seems to be in the ambimonitor object from the Ambisonics Externals for Max/MSP. If I try it with standard objects like e.g. sliders, it behaves correctly. I found a third way for me, more a work-around: when I don’t use preexisting ambimonitor objects but let them generate via scripting too, then it works. It’s not really the solution I was looking for, but it is also probably a problem in the Externals, and not in Max.

If someone wants to take a look at it, here is my sample patch. (I suppose, you’ll need the Ambisonic externals too). The javascript-code is in the comment boxes behind each js object.

– Pasted Max Patch, click to expand. –

You must be logged in to reply to this topic.