problem: connecting to existing objects via scripting


    Matthias S.'s icon
    Matthias S.'s icon
    Matthias S.
    Jan 14 2012 | 5:05 pm
    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.
    BUT: 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?
    cheers, matt

    • Luke Hall's icon
      Luke Hall's icon
      Luke Hall
      Jan 15 2012 | 1:11 am
      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.
    • Matthias S.'s icon
      Matthias S.'s icon
      Matthias S.
      Jan 15 2012 | 9:03 pm
      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.
      Max Patcher
      In Max, select New From Clipboard.
      Show Text
      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.