multiple ops in jitter javascript


    Jan 25 2009 | 5:56 pm
    yet another question about how to articulate something in javascript...
    how do I put multiple operations in an op.?
    I would expect the equivalent of
    jit.op @op !pass pass pass pass
    would be
    input.op(["!pass","pass","pass","pass"],outmatrix);
    (where input and outmatrix are properly defined, and both the same dim/planecount etc.)
    This doesn't provide me with the expected results. Is there another trick I'm missing?
    P

    • Jan 27 2009 | 1:28 am
    • Jan 27 2009 | 6:45 pm
      Hmmm...thanks for the reply. I wouldn't expect it to..."jit.op" isn't initialized like that. To use jit.op in the context of js, you use op as a method on a matrix. For example, the js equivalent of [jit.op @op *] is below.
      I need a way of expressing per-plane operations in the op method, and putting it operations in an array (e.g. "in1matrix.op(["pass","*","pass","pass"],in2matrix);") doesn't work.
      inlets = 2;
      var in1matrix = new JitterMatrix(1,"char",320,240);
      in1matrix.adapt=1;
      var in2matrix = new JitterMatrix(1,"char",320,240);
      in1matrix.adapt=1;
      function jit_matrix(inname){
      if(inlet==1){
      var input2 = new JitterMatrix(inname);
      in2matrix.frommatrix(input2);
      //outlet(0,"jit_matrix",input2.name);
      }
      if(inlet==0){
      var input1 = new JitterMatrix(inname);
      in1matrix.frommatrix(input1);
      in1matrix.op("*",in2matrix);
      //oper.matrixcalc(in1matrix,in2matrix);
      outlet(0,"jit_matrix",in1matrix.name);
      //outlet(0,"jit_matrix",oper.name);
      }
      }
    • Jan 27 2009 | 7:05 pm
      On Jan 27, 2009, at 10:45 AM, pnyboer wrote:
      > I wouldn't expect it to..."jit.op" isn't initialized like that. To
      > use jit.op in the context of js, you use op as a method on a matrix.
      > For example, the js equivalent of [jit.op @op *] is below.
      Wrong. Joshua is correct.
      JitterMatrix.op() is a convenience method for single operators, but
      for more general use of jit.op you will want to use new
      JitterObject("jit.op") as Joshua suggested:
      var myOpper = new JitterMatrix("jit.op");
      myOpper.op = ["!pass", "pass", "pass", "pass"];
      myOpper.matrixcalc([input1,input2],output);
      To do in place processing like your JitterMatrix.op() with a single
      argument, input1 and output would be the same matrix.
      Hope this helps
      -Joshua
    • Jan 27 2009 | 7:25 pm
      Thanks all Joshes for clearing that up. In case there's any confusion when this thread is dug up in a search, it is, of course,
      new JitterObject("jit.op")
      not new JitterMatrix("jit.op").
      Here's a functioning script:
      /* the javascript equivalent of [jit.op @op !pass pass pass pass] */
      autowatch = 1;
      inlets = 2;
      var in2matrix = new JitterMatrix(1,"char",320,240);
      in1matrix.adapt=1;
      var outmatrix = new JitterMatrix(4,"char",320,240);
      outmatrix.adapt=1;
      var opera = new JitterObject("jit.op");
      opera.op = ["!pass", "pass", "pass", "pass"];
      function jit_matrix(inname){
      if(inlet==1){
      var input2 = new JitterMatrix(inname);
      in2matrix.frommatrix(input2);
      }
      if(inlet==0){
      var input1 = new JitterMatrix(inname);
      opera.matrixcalc([input1,in2matrix],input1);
      outlet(0,"jit_matrix",input1.name);
      }
      }