Hi, Following my efforts to make pure Pd versions of some of the zexy essentials, I found some time over the weekend to knock together a pack~ clone. See attached.
It seems to work OK, but like a_unpack~ posted recently it's horribly inefficient compared to the zexy original. It uses some other niceties: a_blocksize~ : reports the blocksize of the parent patch to its outlet a_pow2? : outputs 1 if the input is a power of two 0 otherwise Further contributions and refactoring welcome! Jamie P.S. requires list-rev and list-lastx from list-abs. -- www.postlude.co.uk http://www.linkedin.com/in/jamiebullock
#N canvas 888 76 449 644 10; #X obj 149 172 timer; #X obj 200 171 samplerate~; #X obj 200 231 /; #X msg 200 208 1 \$1; #X obj 149 263 /; #X obj 149 209 / 1000; #X text 44 21 Get the blocksize of the parent patch; #X obj 148 54 bang~; #X obj 149 389 outlet; #X obj 149 106 t b b b; #X obj 149 290 t a a; #X obj 149 359 spigot; #X obj 176 334 a_pow2?; #X obj 176 313 int; #X text -7 435 Bugs!; #X text -2 455 1 Only works for blocksizes >= 64 I think this is to do with a limitation on message scheduling.; #X text -1 490 2 If audio is stopped and then restarted \, the timer will measure the gap and the next blocksize output will be incorrect ; #X text 1 538 To counteract 2 we only allow through power-of-two blocksizes \, which should cover most situations!; #X connect 0 0 5 0; #X connect 1 0 3 0; #X connect 2 0 4 1; #X connect 3 0 2 0; #X connect 4 0 10 0; #X connect 5 0 4 0; #X connect 7 0 9 0; #X connect 9 0 0 0; #X connect 9 1 0 1; #X connect 9 2 1 0; #X connect 10 0 11 0; #X connect 10 1 13 0; #X connect 11 0 8 0; #X connect 12 0 11 1; #X connect 13 0 12 0;
#N canvas 571 25 664 762 10; #X obj 18 94 tabsend~ \$0-elements; #X obj 18 58 inlet~; #X obj 291 350 tabread \$0-elements; #X obj 290 199 until; #X obj 370 153 s \$0-elements; #X msg 370 120 resize \$1; #X obj 290 83 a_blocksize~; #X obj 419 59 table \$0-elements; #X obj 290 261 f; #X obj 321 261 + 1; #X msg 231 197 0; #X obj 200 516 list; #X obj 257 576 outlet; #X obj 290 168 f; #X obj 197 54 bang~; #X obj 290 298 % 64; #X text 191 17 Convert a signal to a list; #X obj 197 83 t b b b b; #X text 289 527 FIX: this is a hack to prevent bangs coming through when initially started. Need to find out why we get bangs.; #X obj 200 538 route bang; #X obj 290 118 t a a a a; #X text 25 615 Bugs:; #X obj 291 399 list-lastx; #X obj 291 452 list-rev; #X text 43 635 - Due to a limitation in a_blocksize~ this abstraction doesn't work properly for blocksizes < 64 What you get in that case is a zero-padded list of 64 elements with the first N elements containing the 'packed' list items.; #X connect 1 0 0 0; #X connect 2 0 22 0; #X connect 3 0 8 0; #X connect 5 0 4 0; #X connect 6 0 20 0; #X connect 8 0 9 0; #X connect 8 0 15 0; #X connect 9 0 8 1; #X connect 10 0 8 1; #X connect 11 0 19 0; #X connect 13 0 3 0; #X connect 14 0 17 0; #X connect 15 0 2 0; #X connect 17 0 11 0; #X connect 17 1 13 0; #X connect 17 2 10 0; #X connect 19 1 12 0; #X connect 20 0 13 1; #X connect 20 1 22 1; #X connect 20 2 15 1; #X connect 20 3 5 0; #X connect 22 0 23 0; #X connect 23 0 11 1;
#N canvas 465 75 268 290 10; #X obj 91 45 inlet; #X obj 110 107 - 1; #X obj 91 134 |; #X obj 91 168 + 1; #X obj 91 77 t a a a; #X obj 91 255 outlet; #X obj 91 193 / 2; #X obj 91 218 ==; #X text 23 8 Outputs 1 if input is a power of two otherwise 0; #X connect 0 0 4 0; #X connect 1 0 2 1; #X connect 2 0 3 0; #X connect 3 0 6 0; #X connect 4 0 2 0; #X connect 4 1 1 0; #X connect 4 2 7 1; #X connect 6 0 7 0; #X connect 7 0 5 0;
#N canvas 417 74 332 459 10; #X obj 27 52 inlet; #X obj 27 109 list-drip; #X obj 27 153 t a b; #X obj 117 269 %; #X obj 54 216 f; #X obj 84 217 + 1; #X obj 27 304 tabwrite \$0-elements; #X obj 27 75 t a a b; #X msg 69 189 0; #X obj 26 398 outlet~; #X msg 159 179 \; \$2-elements resize \$1; #X obj 158 155 pack f \$0; #X obj 132 104 list length; #X obj 26 362 tabreceive~ \$0-elements; #X obj 132 131 t a a; #X obj 190 54 table \$0-elements; #X connect 0 0 7 0; #X connect 1 0 2 0; #X connect 2 0 6 0; #X connect 2 1 4 0; #X connect 3 0 6 1; #X connect 4 0 5 0; #X connect 4 0 3 0; #X connect 5 0 4 1; #X connect 7 0 1 0; #X connect 7 1 12 0; #X connect 7 2 8 0; #X connect 8 0 4 1; #X connect 11 0 10 0; #X connect 12 0 14 0; #X connect 13 0 9 0; #X connect 14 0 3 1; #X connect 14 1 11 0;
#N canvas 275 171 470 401 10; #X obj 165 191 unpack f f f f; #X floatatom 165 314 10 0 0 0 - - -; #X floatatom 192 295 10 0 0 0 - - -; #X floatatom 219 269 10 0 0 0 - - -; #X floatatom 246 250 10 0 0 0 - - -; #X obj 165 130 a_unpack~; #X msg 165 102 1 2 3 4; #X obj 165 74 bang~; #X text 70 27 Patch demonstrating list to signal and back; #X obj 165 162 a_pack~; #X connect 0 0 1 0; #X connect 0 1 2 0; #X connect 0 2 3 0; #X connect 0 3 4 0; #X connect 5 0 9 0; #X connect 6 0 5 0; #X connect 7 0 6 0; #X connect 9 0 0 0;
_______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
