allow saving parameters for users using runtime / standalone

Nov 7, 2006 at 1:18am

allow saving parameters for users using runtime / standalone

hello… just having a problem getting my head around some things… In my patch, I’m trying to facilitate for users to be able to save effect parameters, and other aspects of the patch, such as what effects are open. I’ve read the documentation on data structures in max, although in practice I can’t get an object to save its contents without saving (in max) and maintain its values if you reopen the patch. The preset tool is almost ideal, only I can’t get it to save its values.
Does anyone know how to solve this one?
thank you very much
tom

#28556
Nov 7, 2006 at 6:09am

use [pattrstorage] instead of [preset]. an XML sheet is written of whatever bound to [pattr] or [autopattr] and stored in [pattrstorage].
this works with Max , haven’t tried in MaxRunTime though, might need a little work around if you intend to use MaxRunTime.
Anyway it will give you an idea of how you might want to proceed. the same principle should also work with [coll] or [preset].

each time you store something you just need to set the index value of whatever you store, in a message box, this number in the message box will not move when patch is closed , therefore it makes it easy to use this number when patch is reopened, for instance to recall the last stored index.
hope it helps , there is certainly another way (smarter) to do this ;)

#P user gain~ 521 150 24 100 158 0 1.071519 7.94321 10.;
#P objectname rap;
#P user gain~ 493 150 24 100 158 0 1.071519 7.94321 10.;
#P objectname gee;
#P user gain~ 465 150 24 100 158 0 1.071519 7.94321 10.;
#P objectname kool;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 453 113 100 196617 autopattr something;
#X prestore gee 1 0 139;
#X prestore kool 1 0 142;
#X prestore rap 1 0 139;
#P objectname something;
#P message 120 391 50 196617 recall 2;
#P newex 120 365 62 196617 prepend set;
#P number 322 278 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 322 302 51 196617 recall $1;
#P newex 154 306 74 196617 prepend recall;
#P newex 289 178 72 196617 prepend store;
#P button 270 39 34 0;
#P newex 289 120 27 196617 + 1;
#P newex 289 98 27 196617 i;
#P newex 289 353 115 196617 pattrstorage something;
#X autorestore something.xml;
#X client_rect 14 59 654 299;
#X storage_rect 0 0 640 240;
#P objectname something[1];
#P message 170 248 50 196617 2;
#P number 215 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 108 166 30 196617 t b b;
#P newex 153 275 27 196617 i;
#P newex 108 139 48 196617 loadbang;
#P message 215 210 39 196617 set $1;
#P comment 309 40 100 196617 hit bang to store;
#P connect 14 0 13 0;
#P fasten 9 0 5 0 294 162 220 162;
#P connect 9 0 11 0;
#P fasten 9 0 8 1 294 149 339 149 339 71 311 71;
#P connect 13 0 7 0;
#P connect 11 0 7 0;
#P connect 12 0 15 0;
#P fasten 12 0 7 0 159 338 294 338;
#P connect 8 0 9 0;
#P connect 10 0 8 0;
#P connect 5 0 1 0;
#P connect 6 0 3 1;
#P fasten 1 0 6 0 220 237 175 237;
#P fasten 4 1 6 0 133 215 175 215;
#P connect 3 0 12 0;
#P fasten 4 0 3 0 113 229 158 229;
#P connect 15 0 16 0;
#P connect 2 0 4 0;
#P window clipboard copycount 21;

#87842
Nov 7, 2006 at 7:56pm

that’s amazing help, thank you so much. That’s been a really big help!
many thanks
tom

#87843
Nov 7, 2006 at 10:27pm

does it work with standalones , i havent had the time to try it myself ?

Quote: Tom Haig wrote on Tue, 07 November 2006 11:56
—————————————————-
> that’s amazing help, thank you so much. That’s been a really big help!
> many thanks
> tom
—————————————————-

#87844
Nov 8, 2006 at 12:15am

it works both in runtime and as a standalone… one minor thing though, is there a way to make it automatically save to a designated file name, because in both runtime and a standalone it asks what name and where you want to save the contants of the pattrstorage???
thanks again.
tom

#87845
Nov 8, 2006 at 12:34am

you’ll have to define a default folder for your xml file. usually if you keep your patch and your xml file in the same folder it should not be a prob for max to locate the xml file.
you can write a file for [pattrstorage]‘s stored values by using write message.
use a [sprintf filename%ld] , %ld being the number of the file, this number incrementing ( for example) each time the patch is reopened so that files do not overwrite each other.
or just overwrite the file each time and forget about the number, just give the file a name , might be easier.
use read (filename) message to reload the file when reopening the patch.

if you havent done spend some time on the [pattr] family, it s really worth it.

tc
k

#87846
Nov 8, 2006 at 2:00am

hey, just tried playing around with the read / write functions. However the recall $1 and store $1 don’t seem to be the same thing. I don’t really need to increment target as it saves. I’m only really trying to make a the patch so a user can store one preset of an effect. It seems that the write successfully writes it to the script contained within pattrstorage, however sending the read message doesn’t seem to change the parametrs… any ideas on how to get this working?
thanks
tom

#87847
Nov 8, 2006 at 5:08am

read is not supposed to change any parameters but load any XML file that has been writen.
recall n displays something sotred at n.

i am not sure i am following you, maybe you could send a patch along ;)

Quote: Tom Haig wrote on Tue, 07 November 2006 18:00
—————————————————-
> hey, just tried playing around with the read / write functions. However the recall $1 and store $1 don’t seem to be the same thing. I don’t really need to increment target as it saves. I’m only really trying to make a the patch so a user can store one preset of an effect. It seems that the write successfully writes it to the script contained within pattrstorage, however sending the read message doesn’t seem to change the parametrs… any ideas on how to get this working?
> thanks
> tom
—————————————————-

#87848
Nov 8, 2006 at 5:10am

recall n displays something stored at n.

i am not sure i am following you, maybe you could send a patch along ;)

Quote: Tom Haig wrote on Tue, 07 November 2006 18:00
—————————————————-
> hey, just tried playing around with the read / write functions. However the recall $1 and store $1 don’t seem to be the same thing. I don’t really need to increment target as it saves. I’m only really trying to make a the patch so a user can store one preset of an effect. It seems that the write successfully writes it to the script contained within pattrstorage, however sending the read message doesn’t seem to change the parametrs… any ideas on how to get this working?
> thanks
> tom
—————————————————-

#87849

You must be logged in to reply to this topic.