What should i do to make jsattributes work with pattrstorage

Learn about building and using Max for Live devices.
Post Reply
Surreal
Posts: 560
Joined: Wed May 17, 2006 1:18 am

What should i do to make jsattributes work with pattrstorage

Post by Surreal » Sun Dec 26, 2010 3:11 am

I have a bunch of declared attributes that i am trying to make visible to a pattrstorage that will save within the set automatically.

that is a somewhat convoluted question, i think. sorry.

I tried attaching a pattr to the js, to no avail. i tried an array passed in setvalueof and getvalueof.

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: What should i do to make jsattributes work with pattrstorage

Post by amounra93 » Mon Dec 27, 2010 1:22 am

I had problems with that bit earlier in my js career. I think that you can only actually save one attribute per js with a linked pattr. I merely seperate an array with a symbol, and parse it back in when I reload the patch. Have a look at my collstore js, it might be a possible solution for you:

http://cycling74.com/forums/topic.php?id=29649

There's also a link on my blog page.

Cheers :)
http://www.aumhaa.com for Monomod and other m4l goodies.

Surreal
Posts: 560
Joined: Wed May 17, 2006 1:18 am

Re: What should i do to make jsattributes work with pattrstorage

Post by Surreal » Mon Dec 27, 2010 3:47 am

!!!!!!. After rereading your post, i think I should clarify....i am completely ok with saving one attribute per pattr, but i am having trouble getting it to actually save and recall. with one pattr per attribute, if i hit pattrstorage with grab, it sees all of the new values. But that seems to do me no good.


But thank you for the excellent patch, I may resort to it if a few other options don't pan out.

Surreal
Posts: 560
Joined: Wed May 17, 2006 1:18 am

Re: What should i do to make jsattributes work with pattrstorage

Post by Surreal » Mon Dec 27, 2010 3:52 am

and to be even more clearer...i don't even need the pattrstorage if it can be avoided.

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: What should i do to make jsattributes work with pattrstorage

Post by amounra93 » Mon Dec 27, 2010 5:06 am

Right....sorry, I didn't mean that my patch itself was the solution, just that the method I used for linking the js to a pattr worked. There is no need for custom get/set attribute functions if you are only linking it to a single variable. By default, getvalueof() will be called when the pattr requests it. setvalueof() is called when the pattr pushes a value to the js (most often, when the patch loads). If you call notifyclients() whenever the js receives a new value, then the pattr will call getvalueof() to request the new value. Take a look at those two functions in the script I linked, I think you will see what I mean. Without seeing exactly what you're doing, that's all I have to offer. Maybe you already have that bit working....I think I misread your initial post, as well. I had a good deal of trouble when I first started trying to link pattrs to js's, and almost gave up. Now that I have it working, it works well and is very efficient.

You shouldn't need a pattrstorage, just a pattr that is parameter-enabled.
http://www.aumhaa.com for Monomod and other m4l goodies.

Surreal
Posts: 560
Joined: Wed May 17, 2006 1:18 am

Re: What should i do to make jsattributes work with pattrstorage

Post by Surreal » Tue Dec 28, 2010 5:26 am

Turns out I had the answer after all. My problem was that I was binding directly to the attribute. If I bound to a number object via the middle outlet and set that from my js, I was fine. I was trying to avoid this method for some silly forgotten reason. I think I had it in my head that binding to the attribute should have been easier.

( on second thought, the real culprit is my time away from js-max-patching)

Post Reply