Dynamic parameters within GenExpr functions?

metamax's icon

I can't get any params within a GenExpr function to change. Even the example in the GenExpr guide doesn't work.

Enclosed patcher example:

func(v)  {    
Param add(0);
return v+add;
}
out1 = func(in1);

Sending [jit.gen] a float prepended with "add" does nothing. Global params work fine.

Been at this for hours. Feedback is most appreciated. Cryptic hints, random jokes and non sequiturs are also welcome.

Max Patch
Copy patch and select New From Clipboard in Max.

metamax's icon

Hey thanks. That helps. Although it still looks like a bug because the example given in the GenExpr manual simply does not work. Not to mention, I am building a library of operators to use with require(). ex:

require("func");
out1 = func(in1);

It's one thing to use:

require("func");
Param name(0);
out1 = func(in1, name);

...but I am dealing with matrix functions that have 9 or more param values. ex.

func(c, m) {
vec( c.r*swiz(m,0), c.g*swiz(m,1), c.b*swiz(m,2), c.r*swiz(m,3), c.g*swiz(m,4), c.b*swiz(m,5), c.r*swiz(m,6), c.g*swiz(m,7), c.b*swiz(m,8), c.a );
}

Yet, I can't use the following (outside of the function):
Param mX(1, 0, 0, 0, 1, 0, 0, 0, 1);
out1 = func(in1, elements);

I have to use:
Param mX(1, 0, 0, 0, 1, 0, 0, 0, 1);
out1 = matrix(in1.r, in1.g, in1.b, in1.a, swiz(mX,0), swiz(mX,1), swiz(mX,2), swiz(mX,3), swiz(mX,4), swiz(mX,5), swiz(mX,6), swiz(mX,7), swiz(mX,8) );

Anyway.. I appreciate the help.

metamax's icon

Raja, thanks again for the insight. Your solution is great... though there does appear to be a bug in Gen. Examples from the documentation generate errors. See patch below.

Also, regarding your workaround, it's not necessary to assign an attribute to access the function param. It's just a matter of creating a global param and equating it with the function param in the output arg.

All the best.

Max Patch
Copy patch and select New From Clipboard in Max.

AudioMatt's icon

Where.... where did raja go in this thread! Did our resident asshole delete his posts?!

Roman Thilenius's icon


maybe his creative use of ascii and unicode symbols was too much for the backup script?

AudioMatt's icon

Maybe he used his alien ray to suck up all his old emails. Ever since they ported the email list to this forum it seems like random posts go missing.