#N canvas 432 38 558 578 10;
#X declare -stdpath ./;
#X obj 2 537 cnv 15 552 21 empty empty empty 20 12 0 14 #e0e0e0 #202020 0;
#X obj 3 360 cnv 3 550 3 empty empty inlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 3 455 cnv 3 550 3 empty empty outlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 3 489 cnv 3 550 3 empty empty arguments 8 12 0 13 #dcdcdc #000000 0;
#X obj 78 464 cnv 17 3 17 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X text 110 369 signal;
#X msg 344 186 rms;
#X msg 344 144 bipolar;
#X msg 344 165 absolute;
#X obj 79 369 cnv 17 3 80 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X text 116 385 float;
#X text 169 369 - the signal to be averaged;
#X text 110 464 signal;
#X text 98 497 1) float;
#X text 98 515 2) symbol;
#X text 104 402 bipolar;
#X text 98 418 absolute;
#X text 128 434 rms;
#X obj 231 240 cyclone/scope~ 165 107 2 3 64 -1 1 300 0 0 0 205 229 232 74 79 77 96 98 102 0 empty;
#X text 169 515 - sets mode: bipolar (default) \, absolute or rms;
#X obj 176 145 hsl 150 15 1 50 1 0 adsfadsg ahhah empty -2 -8 0 10 #dcdcdc #000000 #000000 0 1;
#X obj 231 170 noise~;
#X text 181 144 'n' samples to average;
#X text 169 464 - the moving average over the last 'n' samples;
#X text 169 497 - maximum and initial 'n' samples (default 100 \, minimum 1);
#X text 169 402 - outputs average over positive and negative values;
#X text 169 418 - outputs average over absolute values;
#X text 169 434 - outputs 'root mean square' (RMS) values;
#X text 169 385 - 'n': number of last samples to apply the average to;
#N canvas 685 122 425 509 backwards 0;
#X obj 155 181 cyclone/rand~ 10;
#X obj 155 213 cyclone/average~ 44100;
#X obj 155 315 vsl 15 128 -1 1 0 0 gsgg fdssd empty 0 -9 0 10 #dcdcdc #000000 #000000 0 1;
#X text 140 371 0;
#X text 141 307 1;
#X text 136 436 -1;
#X obj 155 275 nbx 9 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X text 32 18 [average~] used to have a control number output in Max 4 \, but Max 5 updated it a signal output that provides sample accurate precision!, f 59;
#X text 32 64 Originally developed in the Max 4 era \, cyclone versions up to '0.2 beta' include this old behaviour of [average~]. Cyclone 0.3 updates all objects to Max 7 \, and [average~] is the only one that may require adapting older patches.;
#X text 32 123 For a float output now \, you have to convert the signal with objects like vanilla's [snapshot~] or [cyclone/snapshot~].;
#X obj 155 245 cyclone/snapshot~ 1;
#X connect 0 0 1 0;
#X connect 1 0 10 0;
#X connect 6 0 2 0;
#X connect 10 0 6 0;
#X restore 459 316 pd backwards \; compatibility;
#N canvas 837 154 443 365 moving 0;
#X obj 248 117 noise~;
#X obj 248 173 cyclone/average~ 8;
#X text 57 24 In the default bipolar mode \, [average~] also acts as a regular moving average filter \, which is a kind of lowpass filter. Listen to the difference below.;
#X obj 114 229 output~;
#X obj 248 229 output~;
#X obj 189 314 declare -stdpath ./;
#X connect 0 0 1 0;
#X connect 0 0 3 0;
#X connect 1 0 4 0;
#X restore 453 261 pd moving \; average filter;
#N canvas 819 103 414 521 more 0;
#X obj 94 399 cyclone/scope~ 189 102 2 3 64 -1 1 300 0 0 0 205 229 232 74 79 77 96 98 102 0 empty;
#X obj 94 371 cyclone/average~ 100;
#X obj 94 294 noise~;
#X obj 179 312 nbx 3 14 1 441 0 0 sadgaf ahah empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 182 262 hsl 150 15 1 100 1 0 adsfadsg ahhah empty -2 -8 0 10 #dcdcdc #000000 #000000 0 1;
#X text 185 261 'n' samples to average;
#X obj 179 287 int;
#X text 23 65 The first argument specifies the maximum buffer size to average the signal. You can change with a float input the number of samples to average but values gretaer than the argument are clipped to that maximum value. The minimum average value is "1" \, which makes it the original signal for the bipolar mode \, or the absolute value of the original signal (for absolute and rms mode). Values smaller than "1" are simply ignored.;
#X obj 179 335 change;
#X text 23 177 Each time [average~] receives a number value \, it clears the samples from the buffer \, even if the number is the same as the previously set number. So you may have to use the [change] object if you don't want the same number to clear the buffer., f 60;
#X text 23 16 A moving/running average outputs a mean between a given number of last samples ('n') for each sample. Only integer values make sense \, so floats are converted to integers!, f 60;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X connect 3 0 8 0;
#X connect 4 0 6 0;
#X connect 6 0 3 0;
#X connect 8 0 1 0;
#X restore 447 295 pd more details;
#N canvas 186 131 1132 382 average 0;
#X obj 90 125 cyclone/average~ 100 bipolar;
#X obj 90 155 cyclone/scope~ 159 105 2 3 64 -1 1 300 0 0 0 205 229 232 74 79 77 96 98 102 0 empty;
#X obj 461 149 cyclone/scope~ 159 105 2 3 64 -1 1 300 0 0 0 205 229 232 74 79 77 96 98 102 0 empty;
#X obj 833 150 cyclone/scope~ 159 105 2 3 64 -1 1 300 0 0 0 205 229 232 74 79 77 96 98 102 0 empty;
#X text 368 26 Absolute mode: only absolute values are considered (negative values atre converted to positive) \, then the mean is applied.;
#X text 756 26 Rms mode: average is the root mean square. The arithmetic mean is performed on the squares of the values \, then the square root is applied.;
#X text 18 31 Bipolar mode (default): a plain arithmetic mean over positive and negative values.;
#X obj 461 117 cyclone/average~ 100 absolute;
#X obj 833 119 cyclone/average~ 100 rms;
#X text 28 298 The bipolar mode also acts as a moving average filter \, as shown in the next subpatch.;
#X text 569 294 RMS values are the usual way to detect and measure signal levels. The absolute average is often similar to the RMS \, so it may work fine in some level detection tasks with the advantage of being more efficient.;
#X obj 90 99 osc~ 500;
#X obj 461 91 osc~ 500;
#X obj 833 95 osc~ 500;
#X connect 0 0 1 0;
#X connect 7 0 2 0;
#X connect 8 0 3 0;
#X connect 11 0 0 0;
#X connect 12 0 7 0;
#X connect 13 0 8 0;
#X restore 441 240 pd average modes;
#X text 53 84 Use [average~] for a signal running/moving average over the last 'n' given samples. The average is done in 3 modes: bipolar (default) \, absolute and rms.;
#X text 351 126 modes:;
#X obj 173 170 nbx 2 15 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 12 #dcdcdc #000000 #000000 0 256;
#X obj 231 212 cyclone/average~ 50;
#X obj 59 240 cyclone/scope~ 165 107 2 3 64 -1 1 300 0 0 0 205 229 232 74 79 77 96 98 102 0 empty;
#X obj 500 69 cyclone/dsponoff~;
#X obj 2 3 header average~;
#X text 22 56 Signal moving average;
#X connect 6 0 36 0;
#X connect 7 0 36 0;
#X connect 8 0 36 0;
#X connect 20 0 35 0;
#X connect 21 0 36 0;
#X connect 21 0 37 0;
#X connect 35 0 36 0;
#X connect 36 0 18 0;
