On Sat, Feb 22, 2014 at 10:54 PM, Pagano, Patrick
<[email protected]> wrote:
> Hello
>
> i have asked this is a few different ways and experimented but i am
> wondering, how does one create "smooth random" numbers that flow between
> each number instead of hoping from number to number?

When trying to translate the settings of a 10 band graphic equalizer
to a smooth spectrum I had a similar issue for which I used cubic
interpolation in three steps. The first two steps involves factor 2
'upsampling' each, which renders a 40 point (+interpolation points)
curve smooth enough for interpolation to 1024 points in one last step.
Attached patch cubic_upsampling.pd shows the interpolation steps done
on a sequence of random numbers.

Katja
#N canvas 143 79 708 617 10;
#N canvas 328 438 667 277 stretch 0;
#X obj 17 178 tabread4 \$0-ampsettings;
#X obj 17 205 tabwrite \$0-stretched-settings;
#X obj 228 97 t f f;
#X obj 228 125 / 2;
#X obj 228 178 tabread4 \$0-stretched-settings;
#X obj 228 205 tabwrite \$0-stretched-settings2;
#X obj 433 100 t f f;
#X obj 433 74 for++ 0 1024;
#X obj 433 180 tabread4 \$0-stretched-settings2;
#X obj 433 206 tabwrite \$0-stretched-settings3;
#X obj 433 127 / 25.6;
#X obj 433 153 + 2;
#X obj 17 78 t f f;
#X obj 17 138 / 2;
#X obj 228 57 for++ 0 43;
#X obj 17 14 inlet;
#X text 305 11 Intermediate tables \$0-stretched-settings and \$0-stretched-settings2
each have 3 points extra for cubic interpolation.;
#X obj 17 40 for++ 0 23;
#X connect 0 0 1 0;
#X connect 2 0 3 0;
#X connect 2 1 5 1;
#X connect 3 0 4 0;
#X connect 4 0 5 0;
#X connect 6 0 10 0;
#X connect 6 1 9 1;
#X connect 7 0 6 0;
#X connect 8 0 9 0;
#X connect 10 0 11 0;
#X connect 11 0 8 0;
#X connect 12 0 13 0;
#X connect 12 1 1 1;
#X connect 13 0 0 0;
#X connect 14 0 2 0;
#X connect 14 1 7 0;
#X connect 15 0 17 0;
#X connect 17 0 12 0;
#X connect 17 1 14 0;
#X restore 60 338 pd stretch;
#N canvas 485 132 310 415 write-settings 0;
#X msg 165 345 arrayviewlistnew;
#X obj 165 374 s \$0-ampsettings;
#N canvas 1 79 450 300 (subpatch) 0;
#X array \$0-ampsettings 13 float 2;
#X coords 0 1 13 0 200 100 1 0 0;
#X restore 69 225 graph;
#X obj 56 23 inlet;
#X obj 56 49 unpack;
#X obj 70 178 tabwrite \$0-ampsettings;
#X obj 70 148 max 0;
#X obj 31 375 outlet;
#X text 80 375 done;
#X obj 89 95 + 1;
#X obj 31 94 t b f f;
#N canvas 358 356 357 340 copy 0;
#X obj 35 13 inlet;
#X obj 35 240 tabread \$0-ampsettings;
#X obj 35 269 tabwrite \$0-ampsettings;
#X obj 88 13 inlet;
#X obj 35 62 f;
#X obj 35 90 sel 1 10;
#X obj 35 210 unpack;
#X msg 35 184 1 0;
#X obj 91 173 tabread \$0-ampsettings;
#X obj 91 202 tabwrite \$0-ampsettings;
#X obj 91 143 unpack;
#X text 146 103 copy from index 10 to 11 and 12;
#X text 182 238 copy from index 1 to 0;
#X text 33 300 copy values so [tabread4] can interpolate later;
#X msg 91 107 10 11 \, 10 12;
#X obj 35 39 bang;
#X connect 0 0 15 0;
#X connect 1 0 2 0;
#X connect 3 0 4 1;
#X connect 4 0 5 0;
#X connect 5 0 7 0;
#X connect 5 1 14 0;
#X connect 6 0 1 0;
#X connect 6 1 2 1;
#X connect 7 0 6 0;
#X connect 8 0 9 0;
#X connect 10 0 8 0;
#X connect 10 1 9 1;
#X connect 14 0 10 0;
#X connect 15 0 4 0;
#X restore 50 121 pd copy;
#X text 101 120 copy if index 1 or 10;
#X text 114 94 shift index number;
#X text 97 23 list: RMS value + slider index;
#X connect 0 0 1 0;
#X connect 3 0 4 0;
#X connect 4 0 10 0;
#X connect 4 1 9 0;
#X connect 6 0 5 0;
#X connect 9 0 5 1;
#X connect 9 0 11 1;
#X connect 10 0 7 0;
#X connect 10 1 11 0;
#X connect 10 2 6 0;
#X restore 60 313 pd write-settings;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-randomnumbers 10 float 2;
#X coords 0 1 10 0 200 100 1 0 0;
#X restore 457 24 graph;
#X obj 26 182 random 100;
#X obj 26 210 / 100;
#X obj 26 94 until;
#X obj 26 123 f;
#X obj 26 40 t b b;
#X obj 26 153 t b f;
#X msg 26 66 10;
#X msg 65 94 0;
#X obj 26 15 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 26 240 tabwrite \$0-randomnumbers;
#X obj 59 123 + 1;
#X obj 60 289 pack;
#N canvas 1 73 450 300 (subpatch) 0;
#X array \$0-stretched-settings 23 float 2;
#X coords 0 1 23 0 200 100 1 0 0;
#X restore 457 160 graph;
#N canvas 1 73 450 300 (subpatch) 0;
#X array \$0-stretched-settings2 43 float 2;
#X coords 0 1 43 0 200 100 1 0 0;
#X restore 458 318 graph;
#N canvas 1 79 450 300 (subpatch) 0;
#X array \$0-stretched-settings3 1024 float 2;
#X coords 0 1 1024 0 200 100 1 0 0;
#X restore 459 474 graph;
#X text 53 14 generate random numbers;
#X text 465 261 upsampled 2 times;
#X text 475 419 upsampled 4 times;
#X text 472 574 upsampled 102.4 times;
#X text 21 461 Katja Vetter Feb. 2014;
#X text 20 384 Smooth 'upsampling' of a random number series by cubic
interpolation. The first two stages must be factor 2 upsampling each.
After that \, the curve is smooth enough for arbitrary upsampling factors.
;
#X connect 1 0 0 0;
#X connect 3 0 4 0;
#X connect 4 0 12 0;
#X connect 4 0 14 0;
#X connect 5 0 6 0;
#X connect 6 0 8 0;
#X connect 6 0 13 0;
#X connect 7 0 9 0;
#X connect 7 1 10 0;
#X connect 8 0 3 0;
#X connect 8 1 12 1;
#X connect 8 1 14 1;
#X connect 9 0 5 0;
#X connect 10 0 6 1;
#X connect 11 0 7 0;
#X connect 13 0 6 1;
#X connect 14 0 1 0;
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to