#N canvas 245 54 731 587 10; #X obj 116 214 *~ 2; #X obj 116 235 -~ 1; #X obj 116 193 phasor~; #X obj 116 172 mtof; #X obj 175 83 nbx 3 14 1.27 127 1 1 empty empty CutOff 0 -8 0 10 -262144 -1 -1 23.4115 256; #X obj 272 83 nbx 3 14 0 800 0 1 empty empty Resonance 0 -8 0 10 -262144 -1 -1 651 256; #X text 103 15 Karlsen 24 fast ladder; #N canvas 0 23 450 300 cpu 0; #X obj 180 174 cputime; #X obj 180 34 loadbang; #X obj 180 118 metro 1000; #X msg 180 62 1; #X floatatom 180 90 0 0 0 0 - - -; #X obj 180 146 t b b; #X obj 180 234 * 0.1; #X obj 180 203 int; #X text 225 90 <-- on/off; #X obj 180 258 outlet; #X connect 0 0 7 0; #X connect 1 0 3 0; #X connect 2 0 5 0; #X connect 3 0 4 0; #X connect 4 0 2 0; #X connect 5 0 0 0; #X connect 5 1 0 1; #X connect 6 0 9 0; #X connect 7 0 6 0; #X restore 8 11 pd cpu; #X floatatom 8 32 5 0 0 0 - - -; #X obj 369 102 s \$0-filter-os-factor; #N canvas 625 53 815 731 ladder-filter 0; #X obj 81 29 inlet~; #X obj 298 634 outlet~; #X obj 627 88 * 0.01; #X obj 87 427 clip~ -1 1; #X obj 85 364 -~; #X obj 404 221 line~; #X obj 404 194 pack 0 100; #X obj 566 574 block~; #N canvas 0 23 478 300 oversampling 0; #N canvas 0 23 823 680 butterworthandallpassfiltering 0; #X obj 177 392 *~ 0.125; #X obj 177 411 rzero~ -1; #X obj 177 430 rzero~ -1; #X obj 177 449 rzero~ -1; #N canvas 0 22 954 605 buttercoef3 0; #X obj 63 51 inlet; #X floatatom 522 134 5 0 0 0 - - -; #X obj 101 153 t f f; #X msg 101 108 0.667; #X msg 80 283 0; #X obj 517 270 loadbang; #X obj 528 298 inlet; #X obj 517 322 f; #X obj 517 346 expr 1 - 2*$f1; #X obj 63 79 t b b b f; #X obj 205 228 * -1; #X obj 163 228 t f f; #X obj 63 391 f; #X obj 30 463 outlet; #X text 515 237 1 to normalize at Nyquist; #X text 59 30 characteristic frequency \, 0(DC) to 1(Nyquist); #X obj 283 470 outlet; #X obj 439 472 outlet; #X text 439 494 imag2a; #X text 283 492 real1; #X text 374 494 real2; #X obj 500 473 outlet; #X text 500 495 imag2b; #X obj 373 470 outlet; #X text 27 485 normalizer1; #X obj 173 470 outlet; #X text 170 492 normalizer2; #X obj 156 436 expr (($f2-$f1)*($f2-$f1)+$f3*$f3); #X obj 63 412 t f f; #X obj 101 176 expr (1 - $f2*$f2) / (1 + $f2*$f2 + 2*$f2*cos($f1)) ; #X obj 163 205 expr 2*$f2*sin($f1) / (1 + $f2*$f2 + 2*$f2*cos($f1)) ; #X obj 80 307 expr (1 - $f2*$f2) / (1 + $f2*$f2 + 2*$f2*cos($f1)); #X obj 522 89 clip 0 1; #X obj 522 111 expr tan($f1*1.57); #X obj 101 131 expr $f1*1.5708; #X text 515 251 0 to normalize at DC; #X text 119 4 3-pole (or zero) Butterworth filter coefficient calculator ; #X text 145 109 "theta" in units of pi/2; #X text 211 138 conjugate pair of pole/zero locations:; #X text 197 155 real part: (1-r*r)/(1+r*r-2rcos(th)); #X text 245 226 imaginary part: 2rsin(th)/(...); #X text 270 282 real-valued one \, theta=0; #X obj 30 439 expr abs($f1-$f2); #X connect 0 0 9 0; #X connect 1 0 29 1; #X connect 1 0 30 1; #X connect 1 0 31 1; #X connect 2 0 29 0; #X connect 2 1 30 0; #X connect 3 0 34 0; #X connect 4 0 31 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 8 0; #X connect 8 0 12 1; #X connect 9 0 12 0; #X connect 9 1 4 0; #X connect 9 2 3 0; #X connect 9 3 32 0; #X connect 10 0 21 0; #X connect 11 0 17 0; #X connect 11 0 27 2; #X connect 11 1 10 0; #X connect 12 0 28 0; #X connect 27 0 25 0; #X connect 28 0 42 0; #X connect 28 1 27 0; #X connect 29 0 23 0; #X connect 29 0 27 1; #X connect 30 0 11 0; #X connect 31 0 16 0; #X connect 31 0 42 1; #X connect 32 0 33 0; #X connect 33 0 1 0; #X connect 34 0 2 0; #X connect 42 0 13 0; #X restore 267 260 pd buttercoef3; #X obj 267 343 nbx 14 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0.166055 256; #X obj 267 327 nbx 14 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0.883693 256; #X obj 267 311 nbx 14 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0.806341 256; #X obj 267 295 nbx 14 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0.0411016 256; #X obj 267 279 nbx 14 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0.193659 256; #X obj 267 359 nbx 14 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 -0.166055 256; #X text 399 162 Here is how to calculate the filter coefficients:; #X text 167 293 A; #X text 257 294 B; #X text 167 332 B; #X text 257 311 C; #X text 167 312 C; #X text 257 279 A; #X text 257 326 D; #X text 257 343 E; #X text 149 350 D \, E; #X text 149 373 D \, F; #X text 257 359 F; #X text 399 214 << Divide by nyquist frequency(half of samplerate) of this subpatch \, which is 22050*16 because of the 16-times oversampling. , f 65; #X text 399 242 << Set X times oversampling; #X obj 177 312 rpole~; #X obj 177 331 *~; #X obj 177 373 cpole~; #X obj 177 350 cpole~; #X text 399 180 << Set desired cutoff frequency for the oversampling (push to reload too); #X obj 267 219 / 22050; #X msg 267 182 12000; #X text 264 379 http://write.flossmanuals.net/pure-data/antialiasing/ ; #X text 399 278 A Normalizer for cpole~; #X text 399 294 B Normalizer for rpole~; #X text 399 311 C Coef for rpole~; #X text 399 327 D Coef for cpole~ real part; #X text 398 344 E (Same \, other cpole~); #X text 398 359 F Coef for cpole~ imag part; #X obj 267 239 /; #X msg 267 161 set \$1; #X obj 177 471 outlet~; #X obj 202 165 inlet; #X obj 282 82 inlet; #X obj 177 205 inlet~; #X text 264 15 These objects make a 3-pole \, 3-zero Butterworth low-pass filter with cutoff at 15kHz (assuming 16x44100 sample rate). The filter was designed using the "buttercoef3" abstraction introduced in patch H13.butterworth.pd in this series.; #X obj 343 145 inlet; #X obj 267 424 samplerate~; #X obj 267 404 t b; #X obj 267 446 outlet; #X obj 177 293 *~ 0; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 3 0 41 0; #X connect 4 0 9 0; #X connect 4 1 8 0; #X connect 4 2 7 0; #X connect 4 3 6 0; #X connect 4 4 5 0; #X connect 4 5 10 0; #X connect 5 0 28 3; #X connect 6 0 28 2; #X connect 6 0 27 2; #X connect 7 0 25 1; #X connect 8 0 26 1; #X connect 9 0 50 1; #X connect 10 0 27 3; #X connect 25 0 26 0; #X connect 26 0 28 0; #X connect 27 0 0 0; #X connect 28 0 27 0; #X connect 28 1 27 1; #X connect 30 0 39 0; #X connect 31 0 30 0; #X connect 39 0 4 0; #X connect 39 0 48 0; #X connect 40 0 31 0; #X connect 42 0 31 0; #X connect 43 0 39 1; #X connect 44 0 50 0; #X connect 46 0 40 0; #X connect 47 0 49 0; #X connect 48 0 47 0; #X connect 50 0 25 0; #X restore 88 205 pd butterworthandallpassfiltering; #N canvas 651 266 629 475 OSSelector 0; #X obj 201 85 sel 0 1 2 3; #X obj 201 3 inlet; #X obj 287 187 outlet; #X msg 287 266 set 1 1 8; #X obj 287 221 t f b; #X obj 248 238 del 1; #X obj 297 288 outlet; #X obj 248 318 outlet; #X text 21 95 Remember to change third argument to same as " X times oversampling " !!!, f 18; #X text 22 15 block~ 1024 1 16; #X text 22 31 block~ 512 1 8; #X text 22 47 block~ 256 1 4; #X text 22 62 block~ 128 1 2; #X text 22 76 block~ 64 1 1; #X text 21 155 I think you also need to change 64 yo something else look above for inspiration., f 18; #X msg 287 102 1; #X msg 287 122 2; #X msg 287 142 4; #X msg 287 162 8; #X msg 287 244 set set 1 1 \$1; #X obj 380 287 f; #X obj 380 308 outlet; #X connect 0 0 15 0; #X connect 0 1 16 0; #X connect 0 2 17 0; #X connect 0 3 18 0; #X connect 1 0 0 0; #X connect 3 0 6 0; #X connect 4 0 19 0; #X connect 4 0 20 1; #X connect 4 1 5 0; #X connect 5 0 3 0; #X connect 5 0 7 0; #X connect 5 0 20 0; #X connect 15 0 2 0; #X connect 15 0 4 0; #X connect 16 0 2 0; #X connect 16 0 4 0; #X connect 17 0 2 0; #X connect 17 0 4 0; #X connect 18 0 2 0; #X connect 18 0 4 0; #X connect 19 0 3 0; #X connect 20 0 21 0; #X restore 153 143 pd OSSelector; #X obj 283 183 nbx 7 15 0 1e+37 0 1 empty empty Freq 44 8 0 10 -262144 -1 -1 12000 256; #X obj 394 159 outlet; #X obj 88 168 inlet~; #X obj 88 226 outlet~; #N canvas 0 23 450 300 oversample-multiplier 0; #X obj 189 60 inlet; #X obj 189 81 sel 0 1 2 3; #X msg 189 102 1; #X obj 178 217 outlet; #X msg 204 122 0.5; #X msg 220 142 0.25; #X msg 236 162 0.125; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 1 1 4 0; #X connect 1 2 5 0; #X connect 1 3 6 0; #X connect 2 0 3 0; #X connect 4 0 3 0; #X connect 5 0 3 0; #X connect 6 0 3 0; #X restore 186 68 pd oversample-multiplier; #X text 85 255 J07.oversampling; #X obj 283 264 outlet; #X obj 153 30 r \$0-filter-os-factor; #X obj 437 215 outlet; #X connect 0 0 5 0; #X connect 0 1 8 0; #X connect 1 0 0 1; #X connect 1 1 0 2; #X connect 1 2 3 0; #X connect 1 3 10 0; #X connect 2 0 0 3; #X connect 4 0 0 0; #X connect 9 0 6 0; #X connect 9 0 1 0; #X restore 296 531 pd oversampling; #X text 519 546 Block for oversampling; #X floatatom 460 573 10 0 0 0 New_Samplerate - -; #X obj 394 40 r \$0-s-35-param; #X text 354 40 Cutoff; #X obj 627 58 r \$0-s-36-param; #X text 575 58 Emphasis; #X obj 86 461 delwrite~ \$0-res 0; #X obj 100 298 delread~ \$0-res; #N canvas 237 102 463 495 4X1-pole 0; #X obj 131 58 inlet~; #X obj 217 56 inlet~; #X obj 131 353 outlet~; #X obj 131 233 rpole~; #X obj 217 152 expr~ 1-$v1; #X obj 146 150 *~; #X obj 146 171 *~; #X obj 131 194 *~; #X obj 131 254 rpole~; #X obj 131 275 rpole~; #X obj 131 296 rpole~; #X connect 0 0 7 0; #X connect 1 0 4 0; #X connect 1 0 5 1; #X connect 1 0 5 0; #X connect 3 0 8 0; #X connect 4 0 3 1; #X connect 4 0 8 1; #X connect 4 0 9 1; #X connect 4 0 10 1; #X connect 5 0 6 0; #X connect 5 0 6 1; #X connect 6 0 7 1; #X connect 7 0 3 0; #X connect 8 0 9 0; #X connect 9 0 10 0; #X connect 10 0 2 0; #X restore 85 393 pd 4X1-pole; #X obj 403 165 clip 0.0001 0.8; #X obj 395 68 * 0.005; #X obj 100 319 *~ 0; #X obj 384 103 t b f; #X obj 402 135 / 1; #X obj 100 341 clip~ -1 1; #X connect 0 0 4 0; #X connect 2 0 20 1; #X connect 3 0 15 0; #X connect 4 0 17 0; #X connect 5 0 17 1; #X connect 6 0 5 0; #X connect 8 0 1 0; #X connect 8 1 10 0; #X connect 8 2 7 0; #X connect 8 3 21 0; #X connect 11 0 19 0; #X connect 13 0 2 0; #X connect 16 0 20 0; #X connect 17 0 3 0; #X connect 17 0 8 0; #X connect 18 0 6 0; #X connect 19 0 22 0; #X connect 20 0 23 0; #X connect 21 0 22 0; #X connect 21 1 22 1; #X connect 22 0 18 0; #X connect 23 0 4 1; #X restore 116 320 pd ladder-filter; #X obj 175 102 s \$0-s-35-param; #X obj 272 102 s \$0-s-36-param; #X obj 369 83 hradio 15 1 1 4 empty empty empty 0 -8 0 10 -262144 -1 -1 3; #X obj 116 147 nbx 3 14 0 127 0 1 empty empty empty 0 -8 0 10 -262144 -1 -1 45 256; #X obj 116 353 *~ 0.5; #X obj 105 382 dac~; #X connect 0 0 1 0; #X connect 1 0 10 0; #X connect 2 0 0 0; #X connect 3 0 2 0; #X connect 4 0 11 0; #X connect 5 0 12 0; #X connect 7 0 8 0; #X connect 10 0 15 0; #X connect 13 0 9 0; #X connect 14 0 3 0; #X connect 15 0 16 0; #X connect 15 0 16 1;