Forums > MaxMSP

Controlling function with pattr

March 30, 2006 | 3:18 pm

Hi there,

I am building a synth which has a number of identical modules, the variables in which need to be independently varied. One of these variables is the volume envelope, which i am controlling using a "function" object.

I am trying to control all the values for these modules from one simple gui, and have managed to sort out all the others (all of which are single values so relatively easy) using pattr’s, but am having trouble controlling the function. The way i would like to do this is to have a function object in the gui, and to link this to the function object in the subpatches, so pattr would be the obvious choice, but i can’t seem to get it to send data in a sensible way.

I have managed to link two functions together with patch cords so that one controls the other, it just seems to stop working when using a pattr.

Does anyone have any suggestions as to how i might go about doing this with pattrs, or is there another way which might work?

Thanks,
Gethin


March 30, 2006 | 3:23 pm

Please send a simple patch illustrating the problem. Otherwise, there’s
no way to know what you’ve done, and no way to sensibly help.

Thanks -
jb


March 30, 2006 | 3:31 pm

Hi, thanks for your reply.

Basically, this patch does what i want it to do:

max v2;
#N vpatcher 92 102 498 502;
#P window setfont "Sans Serif" 9.;
#P message 238 170 31 9109513 dump;
#P message 289 171 28 9109513 clear;
#P user function 76 244 276 344 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X add 111.702126 0.813333 0;
#X add 510.638275 0.693333 0;
#X add 686.170166 0.266667 0;
#X domain 1000.;
#X range 0. 1.;
#X done;
#P user function 73 47 273 147 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X add 111.702126 0.813333 0;
#X add 510.638275 0.693333 0;
#X add 686.170166 0.266667 0;
#X domain 1000.;
#X range 0. 1.;
#X done;
#P fasten 3 0 0 0 243 194 56 194 56 29 78 29;
#P connect 2 0 1 0;
#P connect 0 2 1 0;
#P connect 0 3 3 0;
#P connect 0 3 2 0;
#P pop;

Whereas trying to do it this way doesnt:

max v2;
#N vpatcher 92 102 461 586;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 154 262 106 196617 pattr @bindto function2;
#X prestore 3 0 595.74469 0. 1.;
#P objectname u530000019;
#P window setfont "Sans Serif" 9.;
#P message 238 170 31 9109513 dump;
#P message 289 171 28 9109513 clear;
#P user function 72 303 272 403 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X domain 595.74469;
#X range 0. 1.;
#X done;
#P objectname function2;
#P user function 73 47 273 147 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X add 111.702126 0.813333 0;
#X add 510.638275 0.693333 0;
#X add 595.74469 0.32 0;
#X domain 1000.;
#X range 0. 1.;
#X done;
#P fasten 3 0 0 0 243 194 56 194 56 29 78 29;
#P connect 2 0 4 0;
#P connect 0 2 4 0;
#P connect 0 3 3 0;
#P connect 0 3 2 0;
#P pop;


March 30, 2006 | 3:42 pm

This is what you want, I think. If you need to keep track of the values,
add pattr back to the patch, but the "dump" format of function and the
pattr-value are different, which is why your thing’s not working. Since
you also want to send a "clear" message, you need a message-passing
object, not a value-managing object.

In this case, the mighty pattrforward object is what you need.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 277 287 115 196617 pattrforward function2;
#P message 298 230 31 196617 dump;
#P message 349 231 28 196617 clear;
#P user function 127 388 327 488 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X domain 1000.;
#X range 0. 1.;
#X done;
#P objectname function2;
#P user function 133 107 333 207 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X domain 1000.;
#X range 0. 1.;
#X done;
#P objectname function1;
#P connect 2 0 4 0;
#P connect 0 2 4 0;
#P connect 0 3 2 0;
#P connect 0 3 3 0;
#P fasten 3 0 0 0 303 254 116 254 116 89 138 89;
#P window clipboard copycount 5;


March 30, 2006 | 3:54 pm

Thats brilliant, just what I was looking for, thank you very much!


Viewing 5 posts - 1 through 5 (of 5 total)