'OneCopyControl': a OneCopy for any patch. What do you think?
Spent half the weekend making an abstraction I’m not sure I’ll use – I’m sure many of you will be familiar with it.
My purpose: an abstraction that allows patchers to check after loading if there’s already a patcher open doing something similar. If there is, maybe it will close itself or maybe it will just display a warning, I don’t know yet.
The idea is you place a copy of ‘OneCopyControl’ in your patcher and feed it with an ID string. the ID string indicates what the patcher it is place in is supposed to do. Eg I will [loadmess M4L_IO] for patchers that communicate with M4L. When such a patcher loads it will check if there are any other patchers running with the ‘M4L_IO’ and if there are either close or display a warning.
* the ‘ID’ can be freely set so it can be used for different kinds of patchers of which you only want 1 to be open at any one time: Eg only 1 M4L IO patch, only one midi monitoring patch, etc
* only the newly opened patch receives the bang when there is already a patcher in the same category running (if both the newly-opened and the already-open patcher receive a bang I would end up closing both)
It’s far from elegant, any suggestions welcome!
----------begin_max5_patcher---------- 304.3ocqSErZCCCC8r8Wgwm6FwERKrai9Ara6xnLbRzZ8vwNDqvRWo+6KQIY YszNBgdQfeOI42Sx9HmIS70PPJdR7lfwNxYLBpEf0elIy00oVcfRS5fu7IeJ WzQgPMRvVuNKGBAQgFS2qF3cU4FmEPpVUO3GdGFLeCD1xGi5goJMtcuWBoXm jTQMrhkwsQUjhNz.I1N1deEdY+6fvCEPWWjxeKvjQpswAOrV9G43z4TxxmKM Zqrk3Dm2FVLw4RREhd2+56aZv0wCNad9KQ61cUOtZNN4Fa3WbvFewgMMSqRu 8066JNlhJU7ceDnl1ZlJUZMtK+MPRtE+7IVvWUlNb48OmDipNCBnwoQSyShw bTmkydSVFPzCimLSPmXAR7QWcyMU0nlfZVMS0H1xOw+AAmi9rB -----------end_max5_patcher-----------
in case the ‘OneCopyControl’ patcher doesn’t come through right, here it is:
----------begin_max5_patcher---------- 930.3ocwX10aaBCEF95jeEVrJ0axhrMeual15UUZSc2OUUQRbS7DAh.G0lV0 +6ye.MNsjDC0PuAhMN3y4wG+d7gmGOxYV9ijRGv2.+ELZzyiGMR1kniQUsG4 rN4w4oIkxg4jQd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Sokw7yah8mbXyyt.Ctc7Ki+eeV6tL -----------end_max5_patcher-----------
Your patch doesn’t seem to work for me, even if i correct the zl.slice part?
Attached is my onecopy replacement, mainly to get arround lions annoying auto-restore "features".
ID should be easy to do by adding one argument. Save as abstraction and connect to thispatcher in parent patch. Be careful when you’re still working on you main patch – dispose can bite you.
----------begin_max5_patcher---------- 613.3oc4WFsaaCBEF9ZmmBD81Lq.N3jr8.Lsa1ztdpZBaXILYCVARV5p569L fcmaqiiSaDQS6FP9Xv7e9N+FiueRDLScfqgf2C9FHJ59IQQtP1.QMWGAKoGx KnZ2vfkbsltlCm5umgev3hyD5Jk9w3xckpclBtwMKTSzenjFs32bWrYwyZB6 Go4tJtWIPH31laUQM4aDx0eeKO23uKljVOS.N09..yWXaQKim83bDLmhTY+7 covNqrjV5V.3G4R9dZGoJjsJEai8vjI1loiDId42elOan7f3xiUItNRaae4A oWw1h0bUYIW5qCvWQBzN+mWSkbNSCLJvZEnNmzBFGDGGObldjZbO.HgL2lyI HWpiHt5IdV+DX94VIQuBPbLycdgRWqc1trBQN0DBWdRJ1arWY6VtbHWdRHb4 R9upWqWflpsBoAnj7bU0cWLmgO4wdmwhECYLPjqoy.E.q.ZUiUv8BRBNlbbq .BeE8B6AehV9kJtLbPowhjhFzhDjMONBTLfLPV+.Ael.IiJWCm1zOB3Pb6Zj LeP1f9OiM3EH+mavi.NIWS3ro9HUV8y2dYPjEOCilkD+GjcmHIkLDZVb1joI nltuUP27YqjdRdBfev1byWssbIyGAb6+laR050v3SuIE9JZ0JTTl+EnKARF6 1SdpPF9Mv2BUbOPXgP97ewwoIa7mhJsZ2171rnol.9qrXbsQHoFgR1YL18H5 LnMBFiK6drmRAqRUeHoFMbDu7XkDZLRBEVIYWNzIzDNrRZTUt4gGSmTSAlSI inzEVCdxXnDI7T5TZJMnRJcDJ5s.o5KdXxe.UenJ6C -----------end_max5_patcher-----------
grg – great. ‘value’ is new to me but it’s definitely a lot more elegant and simple than my version. No idea why it wouldn’t work – but irrelevant now as I’ll make one similar to yours!
Ok so here’s my new version, I can’t believe how much simpler it is – thanks for the tip using ‘value’ grg. I am using ‘wclose’ instead of ‘dispose’. If you made changes it will even ask you whether you want to close or not.
question… is it possible to set the value name from an inlet or message box? (I couldn’t find it in the documentation)
----------begin_max5_patcher---------- 630.3ocyV9rbaBCDF+L9oXGt3KtdPXiwzKc53dn8Te.Z5zQFTrUGPhADwNMS d2KZEDSRL+wdHM8BXsHu5662tRvCSrr2JOxxsgOB+.rrdXhkEFRGvpZrkcB8 XXLMGmlcnLIgIT1yLOSwNpv3eUd.hjv2fcLEn1y.tHV+KIDtmJ1wvX2QiKXf flnGRU.OGBKxxJyW78vzuKXajo2O8S0IOlKXgxBAtBKqBlRUg64hc+JiEpLJ mrvatyLf3fW8vaqbm6.+r5+viPMJ296OrvoN62JEJsTvG84LNMt9IhhDT8ni ImBJKT0QcZjjb9evjPJWRczGmLQeY1.IJtT1s6tffSly0q9547lq2YcfyYcP suLgT2mxLKms8SottVqyu8U3LSp6vZDScycHdy8JpNMMvFonraB6HovT0ddN JHV1TfJhv1yp.vAdbLDFKyK6husb1QEow7PphcMPPvNTp+WseIMiKTPBKOmt i0AhVu1fHDNqWgHxoEDQ9eq0tEuqfCF5di8lx6kFF9RMhuwt29k.SWiWPmvX b1m61BLZayiwX1yfW6rx8UiGBikznskmq1+lKyogNcwJxxQgUjKjUn9GSnbG T8JjdohOxCeRWTw+cAJiJPT.A11KLLu8bwxNaQdW1Mw0enw4ZTPIheevK93E zj53OGV4xhrv5rVUbgSFMhkq3BphKEMli9HjFSZOOJhIZdBYDOmtMlgT57GO NT47hkpE831idR3QoxRlUwD2ky8zu5vEKrmFbZYFW8S5S+jKS+jUFMSBz2B7 eZvafAzGA1aAfbM7ewaCwICPu9+y5eICn76eYzaAV0W0n4c0PHY4wDON4ufj aD.l -----------end_max5_patcher-----------
Scripting maybe? Do you need it to be dynamically though? Else just use v #1 and give your ID as an argument.
Thanks grg –
I posted my question on the java script separately.. http://cycling74.com/forums/topic.php?id=36638&replies=1#post-177778
I don’t need it to be dynamic, but I do want it to be a something that can be set from outside the abstraction: eg I may have 3 different patchers of which I only want one copy running. So when I load the second copy of ‘patcher1’ it closes itself because there is already one open, but at the same time there may be a ‘patcher2’ and a ‘patcher3’ that need to be the only one running.
Maybe it’s simpler if I say what it is for: I’m having a number of ‘IO’ patchers that handle the IO with hardware. One is communicating with my Ipad, another with Launchpads, another with M4L. Each listens to a specific udp port so each needs to have only 1 copy running. So each needs a kind of ‘onecopy’ abstraction, but they are independent of each other: the Ipad-IO should only prevent other Ipad-IO patchers from opening.
hmmm. tough to describe! I hope it makes sense…
hm … either you didn’t get the hint in my last post, or I fail to grasp what you are after. Try this:
In the last patch you posted, replace [v OneCopy] with [v #1]. Save it as myonecopy. Then in your patches use
in the next patch use [myonecopy Launchpad-IO] etc.
yup – totally missed you hint and it is _exactly_ what I needed! searching the Max6 documentation for #1 doesn’t give any results.. so I went back to Max5 and now I totally get it. I just got the one using scripting to work, but this definitely is more what I intended. Thanks grg!!
New version (so much simpler, I love it)
----------begin_max5_patcher---------- 622.3ocyVFsjZBCEF9Z3oHCdwdikgDHHt20Y6aQmc5DgrZ5DRbHwpc2Ye2KI fJpXAqBSu4n9m.4+7kbNlObc7VH2QUdfmAeG337gqiiUxH3T+aGubxtTNQYm lmftUt3mdSqFRS2osxbIIaAQrb+.rLqb4T+R7ds2jBsh8N0LBD4GTKK1jyDb p199gGEkazmqVIo+8ZZkk8rKI305gWSzoqXhk+nflpqlADWtN.XfIFainx3g mvXIAI29579ZAiv8LC7oqqIL89Xxu.SfsvC7.xidvhXaLLbbYghxASBZgFQ2 BMPsRCze8zwzdQk41XzHSk24fBZa0LgCHU5jHU0IPbn+rHLL.UxkgpxImpTj kzK.yD3yfW3RUow.eayZNKknosvIz8yo+sZoDnkQnY9njY3Dj46QVojGNjpb VaY+gzuG8LB5rIYiMbjUwDOjKox7bpnZ64EoPT9z.sDP.OoWwT12Js3I.QjA zqnfZAvVFmCRK2Jo.1akyN6vt4iqLZcASnAmcVpImf2eK2fNqWRrejDOtsPz fsUzcQaIdv8m3WsOR05Z5lz2+EtQ0RbzXioIAshH3.RnafMgw9Q3YXXbYyV3 MhF6z73Lw42jytZF8S4kRtoHcuGqugF33hkQUZlfnYRQi4.OYNqXYYTQy5hL lhrfSsfMn08s95FbObSzn4FyJA6vMlxr+mryn4lvdrUg55jSNKasrrAd8g23 49XS2TjeLBgwymdgxwE7gkH1cvt3Z3nw0yNPcEvhtMvVd+DCFwXeHBGkjL8B kg.r8HQBOg8CIWg8vM3ajp1123l2T5w5W3c52q4Fvqte59G.MOZpfC -----------end_max5_patcher-----------
to be saved as an abstraction (I called it ‘OneCopyControl’)
It’s use is for the following situation: when you have different patchers (maybe different versions, maybe different names even) of which you only need 1 running. Add the OneCopyControl to your patcher, give an ID as an argument, and connect a thispatcher object to the outlet. With the ‘ID’ you set a unique identifier: any patcher that opens with that same identifier will close itself because there is already a patcher running carrying out the same function.
I used it to make sure only one patcher listens to a specific udp port. Also if you have a patcher in your extras, but have the same function in a different patcher (or – when you open the ‘extras’ patcher from finder) – it will prevent from 2 copies running at the same time
Am I doing something silly? any comments welcome!
Having the same "opecopy" problem, I just built a patch that didn’t really work: it doesn’t in case the "one copy" patch is opened using a load message sent to pcontrol. So I looked in the forum and discovered a couple of solutions: this one and Peter Castine’s lp.argus. Funnily, I did almost the same patch as basvlk discussed in this topic.
None of them do work in my case.
But I found a solution: a deferlow should be inserted before the wclose is sent.
Here is a patch, but I would be happy if some options were introduced in the original onecopy to control its behavior.
----------begin_max5_patcher---------- 613.3ocuVFrbaCBDF9r7SAU9Pt3pAHBgcu1GfdqW5jICVZsMcPfFIbsSyj28 hPJI1INVxUN5hMrr.+7wtK5wIAgKM6gpPz2P+BED73jf.uoZCAs8CByE6SUh JuagZXmY4uCm0LjE1a8lyfUPoxr64AzaykZEX8ShzZbkQaqj+E71nQ3W80r0 9VmKD1zMR856KgTaiBIIb2jPzEj5+Rn9Nt1n6ZmSyxXen.ZlPX3KCIy75zo8 uxCOPOZQt24veBkYBsHrdnmlLo9mYCiIJiHaoPu9ykIXOFhS7Hg2MR7J5TXI YjvxePSI2e+X.EB0SEF6+LPgMRDoBTno3SRD5kPDZ2Dg4Ix73dFmL6CHS70l L4PUkXM7Nz7Cs5AjQCHSAngLjTWYE5T.ITtpMP1WFN0NSbDkh8fhxiny4rDd caewGxhKNZhdsYVy1d1DoiOo3NKsdaxsQ7XFgTeRaRaXGbPO7z7xwI0jmC5l qquazZ2ZhrFj.cicirxuWP4MHgNCY2.nVCncRkBkpLU.Rtx4c11BkLUXgqXh UQoTackaFdwFb2AILOAI32macH1HiTMEKZWCbWN7COsy3FxhXeFxb5LDuGuK 2ns5xKe3yQT7nQpo3OaJ0T8cNNJlwY3XWy97lz4vSuii7SNTI0u86775r19w HqxrsL8YIz9JH5UUlAUVoVXkF8A9DejOajYYf9vzlbYVgwkK1JAzcm75quJp d2Hcnn5vmQTRI8.RjQUQjd.I1koHBmGwbqJAGQcY6I0MIGY4JnY70UyCTQzd nH53dw5ir6L7e7kTWXhOpRh2mKtgPIWmml7OLz.hRC -----------end_max5_patcher-----------
What about the ‘loadunique’ message to [pcontrol]? Doesn’t that effectively do what you want?
spectro, I didn’t know that. And it even there since Max5!!
Thanks a lot .
Updating lp.argus was broken by the change from Max 4 to 5.
Since what argus did relied on accessing data that Cycling ’74 had changed the API to once (and, therefore, possibly again), I had been rather hoping that they would address the need for a means to prevent multiple instantiations of the same patcher from opening. I gather they have done so with the ‘loadunique’ message. Cool.
Forums > MaxMSP