#N canvas 409 23 562 712 10;
#X declare -stdpath ./;
#X obj 6 683 cnv 15 552 21 empty empty empty 20 12 0 14 #e0e0e0 #202020 0;
#X obj 6 529 cnv 3 550 3 empty empty inlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 6 609 cnv 3 550 3 empty empty outlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 6 645 cnv 3 550 3 empty empty arguments 8 12 0 13 #dcdcdc #000000 0;
#X obj 107 539 cnv 17 3 34 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X obj 107 619 cnv 17 3 17 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X text 136 537 signal;
#X obj 107 580 cnv 17 3 17 empty empty 1 5 9 0 16 #dcdcdc #9c9c9c 0;
#X text 136 579 signal;
#X text 136 619 signal;
#X text 123 656 1) float;
#X text 142 557 float;
#X text 196 579 - trigger signal;
#X text 196 619 - sampled and held signal according to trigger signal;
#X text 196 656 - threshold value (default 0);
#X floatatom 209 244 8 0 0 0 - - - 0;
#X obj 152 230 noise~;
#X obj 152 348 cyclone/cycle~;
#X obj 307 237 cyclone/triangle~ 1;
#X obj 307 287 cyclone/snapshot~ 1;
#X obj 307 318 vsl 20 70 -1 1 0 0 empty empty empty 0 -9 0 10 #f0f0f0 #000000 #000000 0 1;
#X obj 307 214 phasor~ 0.7;
#X obj 348 318 vsl 20 70 -0.99 0.99 0 0 empty empty empty 0 -9 0 10 #dcdcdc #000000 #000000 0 1;
#X obj 209 217 r \$0-thresh;
#X obj 348 397 s \$0-thresh;
#X obj 152 317 expr~ $v1 * 300 + 800;
#X text 86 170 Sample and hold random values from a noise input \, rescaled to 500 - 1100 Hz range:;
#X text 328 383 -1;
#X text 333 309 1;
#X text 334 346 0;
#X text 196 538 - input signal to sample and hold;
#X text 382 349 <= set threshold;
#X text 320 260 <= trigger signal;
#X text 92 255 input =>;
#X obj 152 280 cyclone/sah~ -0.5;
#X text 85 91 When a trigger signal raises above a given threshold \, [sah~] captures a value ("samples") from the input and continually outputs it ("hold") until the trigger signal rises again above the threshold after having dropped below it. This usually synchronizes one signal to the behavior of another.;
#X text 196 558 - sets threshold value;
#N canvas 572 39 559 577 arpeggiator 0;
#X obj 109 361 cyclone/cycle~;
#X floatatom 56 172 0 0 0 0 - - - 0;
#X floatatom 178 172 8 0 0 0 - - - 0;
#X obj 181 146 hsl 100 16 50 150 0 0 empty empty empty -2 -8 0 10 #dcdcdc #000000 #000000 0 1;
#X obj 59 146 hsl 100 16 15 25 0 0 empty empty empty -2 -8 0 10 #dcdcdc #000000 #000000 0 1;
#X obj 109 251 cyclone/sah~;
#X text 260 460 0;
#X text 261 366 1;
#X obj 56 198 phasor~ 20;
#X obj 178 198 cyclone/train~ 77;
#X obj 109 325 cyclone/scale~ 0 1 200 1000;
#X text 50 17 Here we're passing the signal of a [phasor~] (a periodic ramp from 0-1) through the [sah~] object. The trigger signal is from the [train~] object \, which goes from 0 to 1 at a period given in ms \, and from 1 to 0 at half this period. When [train~] goes from 0 to 1 \, it triggers the [sah~] object., f 67;
#X text 50 85 When the period of the [phasor~] and [train~] are out of synchrony \, you may get interesting arpeggio effects. You can try other waveforms for the input to the [sah~]., f 67;
#X text 91 498 The [samphold~] object in Pd vanilla was designed to work with [phasor~]. Conversely \, [sah~] doesn't work well with [phasor~] and works better synchronizing with a signal like a square wave \, or an impulse for example.;
#X obj 109 408 output~;
#X obj 277 371 cnv 19 198 98 empty empty empty 20 12 0 12 #e0e0e0 #404040 0;
#N canvas 0 50 450 250 (subpatch) 0;
#X array \$0-sah 8820 float 0;
#X coords 0 1 8819 0 200 100 1 0 0;
#X restore 276 370 graph;
#X text 332 336 sampled & held [phasor~];
#X obj 211 294 tabwrite~ \$0-sah;
#X obj 211 266 metro 250;
#X obj 211 241 loadbang;
#X connect 0 0 14 0;
#X connect 1 0 8 0;
#X connect 2 0 9 0;
#X connect 3 0 2 0;
#X connect 4 0 1 0;
#X connect 5 0 10 0;
#X connect 5 0 18 0;
#X connect 8 0 5 0;
#X connect 9 0 5 1;
#X connect 10 0 0 0;
#X connect 19 0 18 0;
#X connect 20 0 19 0;
#X restore 449 389 pd arpeggiator \; example;
#X obj 499 69 cyclone/dsponoff~;
#X obj 152 383 output~;
#X obj 2 3 ./header sah~;
#X text 21 64 Sample and hold;
#X obj 20 393 declare -stdpath ./;
#X text 59 460 see also:;
#X obj 409 498 open-else;
#X text 441 469 click;
#X obj 61 482 samphold~;
#X msg 409 470 sh~;
#X text 141 471 Plugdata users or those with ELSE can also use [else/sh~] as a better alternative., f 42;
#X connect 15 0 34 0;
#X connect 16 0 34 0;
#X connect 17 0 39 0;
#X connect 18 0 19 0;
#X connect 18 0 34 1;
#X connect 19 0 20 0;
#X connect 21 0 18 0;
#X connect 22 0 24 0;
#X connect 23 0 15 0;
#X connect 25 0 17 0;
#X connect 34 0 25 0;
#X connect 47 0 44 0;
