#N canvas 558 34 531 698 12;
#X text 15 609 see also:;
#X obj 135 661 fft~;
#N canvas 603 316 560 207 block-interactions 0;
#X text 32 11 INTERACTIONS BETWEEN BLOCK~/SWITCH~ AND OTHER OBJECTS IN PD;
#X text 32 106 If using [send~] or [delwrite~] from a switched-off patch \, the output of corresponding [receive~] and [delread~] objects in other running patches will cycle old input (and sound like garbage). [throw~] may be switched with impunity \, but not [catch~]., f 69;
#X text 32 39 The [dac~] and [adc~] don't work correctly if reblocked to a size other than 64! They also don't work if a parent window is reblocked and the window containing the [dac~] or [adc~] is reblocked back to the default block size and sample rate!, f 69;
#X restore 155 553 pd block-interactions;
#N canvas 707 59 543 582 switch-example 0;
#X obj 109 420 bang~;
#X obj 109 446 t b b;
#X obj 109 472 timer;
#X floatatom 109 501 8 0 0 0 - - - 0;
#X obj 42 164 tgl 19 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000 0 1;
#X msg 54 199 set 4096 1 1;
#X msg 69 247 set 4096 2 1;
#X msg 62 223 set 8192 1 1;
#X msg 76 270 set 4096 1 0.5;
#X msg 83 293 set 4096 1 2;
#X obj 109 529 bng 19 50 10 0 empty empty empty 0 -6 0 8 #dfdfdf #000000 #000000;
#X text 65 164 <-- switch this subpatch on and off;
#X text 186 383 <-- creation arguments (if any) initialize blocking, f 40;
#X text 175 293 <-- upsampled by factor of 2;
#X text 184 270 <-- downsampled by factor of 2;
#X text 164 246 <-- double overlap;
#X text 157 223 <-- bigger block size;
#X text 149 198 <-- block size 4096 \, no overlap \, no resampling;
#X text 173 502 <-- measured time (msec) between blocks;
#X text 58 15 DSP in this subwindow is turned on and off by the [switch~] object. Any subwindows of this window can also be switched off here. If a patch and a superpatch both have switches \, both must be "on" for DSP to run in the patch., f 61;
#X text 57 83 [switch~] takes optional arguments the same as [block~]. If you supply arguments to [switch~] \, the patch will be switched AND reblocked., f 61;
#X text 185 416 (args are blocksize \, overlap \, up/downsampling \, DSP computation offset), f 40;
#X obj 42 382 switch~ 4096 1 1 0;
#X msg 90 317 set 4096 4 1 1024;
#X text 220 317 <-- DSP computation offset by 1024 samples (which is the hop size of 4096 window and overlap of 4)., f 42;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 1 1 2 1;
#X connect 2 0 3 0;
#X connect 3 0 10 0;
#X connect 4 0 22 0;
#X connect 5 0 22 0;
#X connect 6 0 22 0;
#X connect 7 0 22 0;
#X connect 8 0 22 0;
#X connect 9 0 22 0;
#X connect 23 0 22 0;
#X restore 155 501 pd switch-example;
#N canvas 551 180 567 287 switch-bang 0;
#X text 50 15 You can use the switch~ object to single-step dsp in a subpatch. This might be useful for block operations that don't want to be synced to the sample clock: loading a window function in a table \, or copying one table to another:, f 65;
#X obj 139 183 noise~;
#X obj 36 140 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X text 38 93 Note: DSP needs to be on;
#X text 62 133 click to randomize the table at right, f 20;
#X obj 139 227 tabwrite~ noise;
#X obj 36 227 switch~ 4096;
#X obj 278 117 cnv 19 254 138 empty empty empty 20 12 0 12 #ffffff #404040 0;
#N canvas 0 22 450 300 (subpatch) 0;
#X array noise 4096 float 2;
#A color 0;
#A width 2;
#X coords 0 1 4096 -1 256 140 1 0 0;
#X restore 277 116 graph;
#X connect 1 0 5 0;
#X connect 2 0 5 0;
#X connect 2 0 6 0;
#X restore 155 527 pd switch-bang;
#X obj 87 609 ../3.audio.examples/G04.control.blocksize;
#X obj 87 631 ../3.audio.examples/J07.oversampling;
#X msg 24 539 \; pd dsp \$1;
#X obj 178 661 bang~;
#X text 14 661 and the objects:;
#X obj 5 50 cnv 1 520 1 empty empty empty 8 12 0 13 #000000 #000000 0;
#N canvas 710 115 570 368 reference 0;
#X obj 9 92 cnv 5 550 5 empty empty INLET: 8 18 0 13 #202020 #000000 0;
#X obj 9 215 cnv 2 550 2 empty empty OUTLETS: 8 12 0 13 #202020 #000000 0;
#X obj 9 252 cnv 2 550 2 empty empty ARGUMENTS: 8 12 0 13 #202020 #000000 0;
#X obj 8 350 cnv 5 550 5 empty empty empty 8 18 0 13 #202020 #000000 0;
#X text 100 107 float -;
#X text 129 224 NONE;
#X text 107 141 bang -;
#X text 136 262 1) float - set block size (default 64).;
#X text 135 282 2) float - set overlap for FFT (default 1).;
#X text 135 302 3) float - up/down-sampling factor (default 1).;
#X obj 26 27 block~;
#X text 95 26 - set block size \, overlap and up/downsampling;
#X text 22 56 [switch~];
#X text 96 56 - also switch subpatches if invoked as [switch~];
#X text 159 107 in the case of [switch~] \, nonzero turns DSP on for the containing window \, zero turns DSP off., f 53;
#X text 159 141 in the case of [switch~] \, when turned off \, computes just one DSP cycle on the containing window., f 53;
#X text 135 322 4) float - DSP computation offset in samples (default 0).;
#X text 64 176 set <list> -;
#X text 159 176 set argument values (size \, overlap \, up/downsampling \, DSP computation offset)., f 53;
#X restore 369 17 pd reference;
#X text 5 16 [block~] and [switch~] -;
#X text 188 9 set block size and on/off control for DSP, f 22;
#X obj 5 595 cnv 1 520 1 empty empty empty 8 12 0 13 #000000 #000000 0;
#X text 462 18 <= click;
#X text 189 68 [block~] with window's default values;
#X text 34 201 In addition \, [switch~] allows you to switch DSP on and off for the owning patch window and all of its subwindows are also switched. (If a subwindow of a switched window is also switched \, both switches must be on for the subwindow's audio DSP to run. Pd's global DSP must also be on.), f 68;
#X text 34 280 A [switch~] or [block~] object without arguments does not reblock audio computation - in other words \, block size and sample rate are as in the parent patch., f 68;
#X text 34 328 [switch~] also takes a "bang" message that computes one block of DSP if it's switched off. This is useful for pre-computing waveforms \, window functions or also for video processing., f 68;
#X text 34 379 Pd's default block size is 64 samples. The [inlet~] and [outlet~] objects reblock signals to adjust for differences between parent and subpatch \, but only power-of-two adjustments are possible. So for "normal" audio computations \, all blocks should also be power-of-two in size. HOWEVER \, if you have no [inlet~] or [outlet~] you may specify any other block size. This is intended for later use in video processing., f 68;
#X text 282 501 <-- click and open example;
#X text 265 527 <-- 'bang' lets you single-step DSP;
#X text 313 553 <-- BUG! incompatibilities;
#X text 341 570 to other objects, f 22;
#X obj 24 504 set-dsp-tgl;
#X text 55 508 DSP on/off;
#X text 85 95 args: block size \, overlap \, up-downsampling \, offset;
#X obj 76 68 block~ 64 1 1 0;
#X text 34 122 The [block~] and [switch~] objects set the block size \, overlap \, up/down-sampling ratio and DSP computation offset for the patch window. (The overlap and resampling ratio are relative to the super-patch.) You may have at most one [block~] or [switch~] object in any window., f 68;
#X text 318 661 updated for Pd version 0.56;
#X connect 25 0 7 0;
