bang when patch is unlocked

Mar 15, 2011 at 4:41am

bang when patch is unlocked

Anyone know how to receive a bang when the patch it unlocked? I can’t seem to find the object/workaround.

Thanks.

#55531
Mar 15, 2011 at 6:00am

This is something that you can get at via javascript. this.patcher.locked will return a 0 (unlocked) or 1 (locked).

-Ben

#199758
Mar 15, 2011 at 6:55am

Hello,

[quebec] external in my “UFO…” package in the Toolbox page do that ;
(mac only, but sources with) …

HTH.

#199759
Mar 17, 2011 at 12:10am

thank you both. Ben, do you think you can post an example for those of us who aren’t Javascript programmers?

#199760
Mar 17, 2011 at 7:57am

Hello,

put that in a [js] object :

function bang ()
{
    outlet (0, this.patcher.locked);
}

and bang it to query lock state of the patcher.

HTH.

#199761
Mar 17, 2011 at 11:08pm

I don’t think the OP wants to check the state of the patch, IMO he wants to trigger a bang the very moment the patch gets unlocked.

#199762
Mar 19, 2011 at 6:53am

Post the code below in a js object, then send the message poll to the object. It will check the state of the patch every 100 milliseconds. If you want to find out the state of the patch just once, send the message lockstate.

var polling = new Task(lockstate);

function lockstate()
{
outlet(0, this.patcher.locked);
}

function poll()
{
polling.interval = 100;
polling.repeat();
}

#199763

You must be logged in to reply to this topic.