[sharingisfun] passing messages via pattrstorage

Sep 25, 2007 at 8:19pm

[sharingisfun] passing messages via pattrstorage

I’ve long been craving a way to pass messages via pattrstorage to other parts of the patch. I finally realized a way to do it!
For example if you have a pattrstorage with greedy on, and you want to pass some subpatch a “bang” message, I’ve had to rely on named number boxes and a “sel” or “t” object to convert the integer into a bang. So if I want to send the message:
MovieModule::Reverse bang
into pattrstorage and have it received in the MovieModule, I can do that with this small javascript:

/*
used to pass symbols (or anything else) to patches that are pattr-ized. name the js object that hosts this with a scripting name (such as “jim”) then you can send messages like “Patch::SubPatch::jim hello” to the patch that contains this.
js by Peter Nyboer pnyboer at slambassador dot com
*/

//begin “getset.js”

autowatch = 1;
var thevalue = “none”;
var thevalue_ = “none”;
function getvalueof() {
return thevalue;
}
function setvalueof(v) {
thevalue= v;
if(thevalue != thevalue_) {
outlet(0,thevalue);
//post(“SET”,thevalue);
}
thevalue_ = thevalue;
}
function setthevalue(v){
thevalue= v;
thevalue_ = thevalue;
notifyclients();
}
//end “getset.js”

//begin “getset.help”

#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 33 148 211 196617 used for storing a symbol or arbitrary value for pattr;
#P window linecount 1;
#P newex 31 109 47 196617 print ??;
#P newex 198 88 32 196617 print;
#P objectname p[1];
#P message 195 44 73 196617 something jim;
#P message 71 32 31 196617 hello;
#P message 31 32 34 196617 jones;
#P newex 31 58 100 196617 prepend setthevalue;
#P newex 198 115 60 196617 autopattr q;
#X prestore something 1 0 jim;
#P objectname q;
#P newex 198 65 75 196617 pattrstorage p;
#X client_rect 288 399 661 627;
#X storage_rect 0 0 640 240;
#P objectname p;
#P newex 31 79 62 196617 js getset.js;
#P objectname something;
#P comment 96 80 100 196617 named “something”;
#P connect 7 0 2 0;
#P connect 1 0 9 0;
#P connect 4 0 1 0;
#P connect 6 0 4 0;
#P connect 5 0 4 0;
#P window clipboard copycount 11;

//end “getset.help”

#33814
Sep 26, 2007 at 9:00am

I’m a little confused about the utility of this; what does this do
that you can’t do without JS? You can set the value of any pattr-
compatible object via pattrstorage, even that of objects which aren’t
in the pattrstorage’s client list. And for non-value messages to
named objects, pattrforward. Am I missing something here?

jb

Am 25.09.2007 um 22:19 schrieb pnyboer:

> I’ve long been craving a way to pass messages via pattrstorage to
> other parts of the patch. I finally realized a way to do it!
> For example if you have a pattrstorage with greedy on, and you want
> to pass some subpatch a “bang” message, I’ve had to rely on named
> number boxes and a “sel” or “t” object to convert the integer into
> a bang. So if I want to send the message:
> MovieModule::Reverse bang
> into pattrstorage and have it received in the MovieModule, I can do
> that with this small javascript:

#113136
Sep 27, 2007 at 10:46pm

well, I could pass messages before to named objects or a receive, but it wouldn’t be stored, then? I suppose referring to “bang” is a poor example, since I don’t need to store the message “bang”.

I’m using pattrstorage as a hub for communication to everwhere else. I can assemble messages in a javascript somewhere, for example, and send them to pattrstorage:
1Channel::FileName “Macintosh HD:/Sounds/Drum Loop.aif”
2Channel::FileName “Macintosh HD:/Sounds/Bweep Boop.aif”
1EffectsGroup::1VST “super delay”

With getset.js, I can just drop it in my patch, name it, and treat it the same as a number box. Additionally, the FileName or VST name gets stored to the preset. I haven’t found another way to store symbols to a pattrstorage preset besides umenu/ubumenu.

Maybe it is a bit specific for my needs and brain, but it is useful. I have a single receive hooked up to a global pattrstorage, and everything goes thru that. I guess I could use pattrforward to send my messages, but I didn’t think of that long ago when I started using pattrstorage!

Besides that, it is a decent example of getting js communicating with pattr.

#113137

You must be logged in to reply to this topic.