[PD] Filling arrays

Frank Barknecht fbar at footils.org
Wed Apr 20 11:45:20 CEST 2005


Hallo,
Carlos Pita hat gesagt: // Carlos Pita wrote:

> Do you know how can I fill an arbitrarily
> sized array with a line strip? The goal
> is to write square, sawtooth, triangular
> and other simple waves like that and then
> loop with tabread4~. The array size
> can be reconfigured, so I don't want to
> load the table from a presampled file
> but instead to resample it from the original
> function when the array is resized.
> Doing it with line~ is too awkward,
> scheduling delays and like that, and
...

You can use [vline~] instead, which accepts messages consisting of
line segments and is not limited to only one segment.

See attached patch for one possible way to use it. It would need some
tinkering to adapt to variable array sizes, but I hope, the basic
principle becomes clear, the only thing left to do is scaling the
values send to vline~ dynamically to match the current array size. And
of course you'd need to decide on a way how to specify the line
segments in regard to array size (like: going from 0 to 1 over half
the array size could become a message like: [0 1 0.5(, then you'd need
to multiply 0.5 with the arraysize and divide by samplerate/1000.)

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
          _ __latest track: "scans" _ http://footils.org/cms/show/41
-------------- next part --------------
#N canvas 501 188 661 469 10;
#X obj 429 287 table x 512;
#X obj 235 260 vline~;
#X obj 257 335 tabwrite~ x;
#X obj 235 95 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 330 169 samplerate~;
#X obj 235 118 t b b b;
#X obj 274 225 / 1;
#X obj 330 196 / 1000;
#X obj 235 188 unpack 0 0 0;
#X obj 314 225 / 1;
#X text 350 223 scale samples to msecs.;
#X msg 387 79 \; x const 0 \; pd dsp 1 \;;
#X msg 235 143 0 0 0 \, 1 10 \, 0.3 40 10 \, 0.8 100 50 \, 0 302 210
;
#X connect 1 0 2 0;
#X connect 3 0 5 0;
#X connect 4 0 7 0;
#X connect 5 0 12 0;
#X connect 5 1 2 0;
#X connect 5 2 4 0;
#X connect 5 2 11 0;
#X connect 6 0 1 1;
#X connect 7 0 6 1;
#X connect 7 0 9 1;
#X connect 8 0 1 0;
#X connect 8 1 6 0;
#X connect 8 2 9 0;
#X connect 9 0 1 2;
#X connect 12 0 8 0;


More information about the Pd-list mailing list