[sharingisfun] passing messages via pattrstorage


    Sep 25 2007 | 8:19 pm
    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"
    //end "getset.help"

    • Sep 26 2007 | 9:00 am
      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:
    • Sep 27 2007 | 10:46 pm
      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.