Dynamic parameters within GenExpr functions?


    Nov 11 2015 | 4:50 am
    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.

    • Nov 11 2015 | 9:36 am
      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.
    • Nov 12 2015 | 6:48 am
      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.