getcell equivalent in jit.expr?

Dec 31, 2007 at 5:03pm

getcell equivalent in jit.expr?

I’ve been simplifying some patches with jit.expr, and I’d like to use specific scalar cell values from an input matrix within the calculations. Is there a simple way to do this? The only way I have been able is by making a separate matrix that takes getcell messages and outputs to additional inputs of a jit.expr object. Such a method works, but seems very wasteful to me. It’s also not easy to expand to multiple simultaneous cells without making a new matrix for finding each value needed. Is there a way of doing this inside the jit.expr itself?

For example, with a 1D vector I want the value when cell[0]==50

Initially I tried “sum((cell[0]==50)*in(0))”, but found there was no summation command.

Here is a simple patch to hopefully explain visually.

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 237 152 26 9109513 print;
#P message 311 115 56 9109513 getcell $1 0;
#P window setfont “Sans Serif” 14.;
#P comment 177 341 444 9109518 This pwindow shows the point from which I’d like to get a scalar value;
#P window linecount 2;
#P comment 359 239 157 9109518 Trying to get scalar value at this input cell;
#P window setfont “Sans Serif” 9.;
#P number 310 252 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P user jit.pwindow 135 283 514 52 0 1 0 0 1 0;
#P toggle 66 89 15 0;
#P window linecount 1;
#P newex 66 113 50 9109513 qmetro 50;
#P newex 136 250 153 9109513 jit.expr @expr (cell[0]==in[1])*in[0];
#P button 137 46 15 0;
#P newex 137 61 45 9109513 loadbang;
#P newex 137 133 110 9109513 jit.matrix 1 float32 512 1;
#P user jit.pwindow 136 178 514 52 0 1 0 0 1 0;
#P newex 137 97 160 9109513 jit.expr @expr “abs(sin(norm[0]*10))”;
#P newex 137 79 110 9109513 jit.matrix 1 float32 512 1;
#P window setfont “Sans Serif” 14.;
#P window linecount 2;
#P comment 256 51 117 9109518 Starting Matrix , arbitrary function;
#P connect 9 0 8 0;
#P fasten 4 0 7 0 142 165 123 165 123 243 141 243;
#P connect 7 0 10 0;
#P connect 6 0 5 0;
#P connect 5 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 4 0;
#P connect 14 0 4 0;
#P connect 8 0 4 0;
#P connect 4 0 3 0;
#P connect 4 1 15 0;
#P fasten 11 0 7 1 315 274 298 274 298 240 284 240;
#P connect 11 0 14 0;
#P window clipboard copycount 16;

#35166
Dec 31, 2007 at 11:45pm

This sort of thing isn’t possible within jit.expr syntax (without
leveraging instances of jitter objects), but is pretty simple to do
within an abstraction using jit.matrix.

Something like the following should work:
#P user jit.pwindow 19 318 82 62 0 1 0 0 1 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 20 88 134 196617 jit.noise 1 float32 320 240;
#P button 180 34 15 0;
#P newex 180 49 45 196617 loadbang;
#P newex 180 69 134 196617 jit.matrix 1 float32 512 1;
#P newex 180 89 194 196617 jit.expr @expr “abs(sin(norm[0]*10))”;
#P newex 20 296 141 196617 jit.expr @expr “in[0]*in[1]“;
#P number 134 143 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 134 196 134 196617 jit.matrix 1 float32 512 1;
#P newex 134 163 27 196617 t b i;
#P message 151 218 144 196617 srcdimstart $1 , srcdimend $1;
#P newex 151 246 175 196617 jit.matrix 1 float32 1 @usesrcdim 1;
#P toggle 20 44 15 0;
#P newex 20 68 64 196617 qmetro 50;
#P window linecount 2;
#P comment 196 140 141 196617 this seems easier than trying to wrangle
jit.expr syntax.;
#P user panel 114 131 232 146;
#X brgb 255 255 255;
#X frgb 205 219 224;
#X border 4;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 14 0 9 0;
#P connect 2 0 14 0;
#P connect 9 0 15 0;
#P fasten 7 0 4 0 139 237 156 237;
#P connect 12 0 11 0;
#P connect 13 0 12 0;
#P fasten 10 0 7 0 185 185 139 185;
#P connect 11 0 10 0;
#P connect 4 0 9 1;
#P connect 8 0 6 0;
#P connect 6 0 7 0;
#P connect 6 1 5 0;
#P connect 5 0 4 0;
#P connect 3 0 2 0;
#P window clipboard copycount 16;

#119484

You must be logged in to reply to this topic.