making long lists from pairs

Jun 14, 2007 at 1:51pm

making long lists from pairs

Dear maxers,

I’m trying to build a patch that takes a row of pixel values from a matrix and maps them to the strength of harmonic partials to feed [oscbank~]. The patch below iters through the list and pairs each value with a partial. But I can’t find a way to format the resulting pairs back into a list. Obviously there are too many pairs to use [pack], and I can’t find a way for [coll] to output a list…any ideas?

Christopher

max v2;
#N vpatcher 155 64 700 586;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 15 340 32 196617 print;
#P newex 69 372 62 196617 prepend set;
#P newex 69 427 31 196617 dac~;
#P newex 69 399 62 196617 oscbank~;
#P newex 285 125 79 196617 vexpr $i1/255;
#P newex 69 311 54 196617 pack 0. 0.;
#P message 69 94 169 196617 128 14 56 25 34 21 113 49 170 1;
#P number 204 249 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 176 273 38 196617 * 100;
#P newex 113 169 73 196617 t i b;
#P newex 69 115 86 196617 t b l b;
#P newex 113 202 40 196617 / 255.;
#N counter;
#X flags 0 0;
#P newobj 176 228 66 196617 counter;
#P newex 113 144 25 196617 iter;
#P comment 244 250 67 196617 Fundimental;
#P comment 219 275 90 196617 Harmonic partials;
#P comment 123 224 36 196617 Amps;
#P message 129 350 219 196617 set 110 0.5 220 0.4 330 0.3 440 0.2 550 0.2;
#P window linecount 2;
#P comment 69 57 210 196617 Input a list of 200 or so numbers (from jit.spill) with values from 0-255;
#P comment 129 321 268 196617 How to format the pairs back into a list that looks something like…?;
#P comment 6 137 80 196617 bang out the list when formed;
#P fasten 15 0 20 0 74 334 20 334;
#P connect 14 0 10 0;
#P fasten 12 0 15 0 181 299 74 299;
#P fasten 3 0 17 0 134 392 74 392;
#P connect 19 0 17 0;
#P connect 17 0 18 0;
#P fasten 17 0 18 1 74 421 95 421;
#P fasten 10 1 7 0 112 138 118 138;
#P connect 7 0 11 0;
#P connect 11 0 9 0;
#P connect 9 0 15 1;
#P connect 11 1 8 0;
#P connect 8 0 12 0;
#P fasten 10 2 8 2 150 147 209 147;
#P connect 13 0 12 1;
#P pop;

#32463
Jun 14, 2007 at 2:09pm

Peter Elsea’s LObjects are your friend!

If you know how long your final list needs to be, you could use his Lin object, with an argument specifying the total list length.

J.

#106857
Jun 14, 2007 at 10:15pm

Quote: Christopher Keyes wrote on Thu, 14 June 2007 06:51
—————————————————-
> Dear maxers,
>
> I’m trying to build a patch that takes a row of pixel values from a matrix and maps them to the strength of harmonic partials to feed [oscbank~]. The patch below iters through the list and pairs each value with a partial. But I can’t find a way to format the resulting pairs back into a list. Obviously there are too many pairs to use [pack], and I can’t find a way for [coll] to output a list…any ideas?
>
>

You’ve got an order of operations problem with your patch which I haven’t addressed, but here’s a list solution:

#P window setfont “Sans Serif” 9.;
#P number 326 348 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 329 310 27 196617 * 2;
#P newex 66 341 46 196617 zl group;
#P newex 329 197 34 196617 zl len;
#P newex 47 400 32 196617 print;
#P newex 285 125 79 196617 vexpr $i1/255;
#P newex 69 311 54 196617 pack 0. 0.;
#P message 69 94 169 196617 128 14 56 25 34 21 113 49 170 1;
#P number 204 249 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 176 273 38 196617 * 100;
#P newex 113 169 73 196617 t i b;
#P newex 69 115 86 196617 t b l b;
#P newex 113 202 40 196617 / 255.;
#N counter;
#X flags 0 0;
#P newobj 176 228 66 196617 counter;
#P newex 113 144 25 196617 iter;
#P comment 244 250 67 196617 Fundimental;
#P comment 219 275 90 196617 Harmonic partials;
#P comment 123 224 36 196617 Amps;
#P window linecount 2;
#P comment 69 57 210 196617 Input a list of 200 or so numbers (from jit.spill) with values from 0-255;
#P comment 6 137 80 196617 bang out the list when formed;
#P connect 18 0 17 1;
#P connect 18 0 19 0;
#P fasten 8 1 5 0 112 138 118 138;
#P connect 8 1 16 0;
#P connect 12 0 8 0;
#P fasten 10 0 13 0 181 299 74 299;
#P connect 5 0 9 0;
#P connect 9 0 7 0;
#P connect 7 0 13 1;
#P connect 9 1 6 0;
#P connect 6 0 10 0;
#P fasten 8 2 6 2 150 147 209 147;
#P connect 11 0 10 1;
#P connect 16 0 18 0;
#P connect 13 0 17 0;
#P connect 17 0 15 0;
#P window clipboard copycount 20;

#106858
Jun 15, 2007 at 2:44am

Thanks mzed!

Great solution and thanks for pointing out the operation order problem…easy to fix.

Christopher

#106859

You must be logged in to reply to this topic.