(simple question) detect if a patcher is a parent patcher or a subpatcher ?

Feb 2, 2012 at 6:12pm

(simple question) detect if a patcher is a parent patcher or a subpatcher ?

hello,
a rather straightforward question : is there such an object, that would detect if the patcher within which it is has a parent patcher at all ? IE something that would allow us to route audio output towards either this patcher’s outlets, or directly towards dsp ? it seems a little bit silly for me not to find it.
The IO abstraction should do this, but i can’t figure out how…

#61583
Feb 2, 2012 at 8:25pm

Of the top of my head, a simple Javascript object should do this. Send the message ‘hasParent’ to it and you’ll get a 1 if it has a parent or a 0 if it doesn’t.

E.g,

inlets = 1;
outlets = 1;

function hasParent()
{
   var p = this.patcher;
   if (p.parentpatcher)
      //then
         outlet(0, 1);
      else
         outlet(0, 0);
}
#222261
Feb 4, 2012 at 10:53pm

Thanks ! i don’t know a thing about js. This seems to work perfectly.

#222262
May 31, 2012 at 3:36am

Hum, this does not seem to work with a loadbang.

For example, add this code to a js object connected to a loadbang that sends out the hasParent message.

On loadbang, the javascript return that the patcher does not have a parent. On subsequent bangs it does!

#222263
May 31, 2012 at 4:03am

Sounds like at the point that the loadbang is triggered, the parent-child relationship has not been fully established. I don’t know if that was a deliberate decision or whether it’s just a bug (e.g. the relationship is setup after all calls to loadbang have completed rather than before it)

#222264

You must be logged in to reply to this topic.