Frank Barknecht wrote:
Hallo,
first: thanks a lot for explaining the DC effects to you and to Lex. I did however ask my question slightly ambivalent. I also would be interested in why and how a [hip~ 5] filter removes a DC offset.
It's convenient to look at DSP in the time domain to answer this.
A factory worker (a signal processor) is tasked to:
at the sample rate (as fast as they're delivered),
The worker only thinks about the current number and the last number before it was crossed out.. Numbers range in value from -1 to +1.
In a two-sample crude lowpass: Sout = (Sample1 + Sample0)/2 This sums current (Sample1) and previous (Sample0) input samples and divides by 2 (otherwise this filter would have a gain of 2). This preserves DC because any two adjacent identical samples are output without alteration.
What about: Sout = (Sample1 - Sample0)/2 ( We still divide by 2 because 1 -(-1) gives a peak amplitude of 2.) This subtracts any two adjacent samples. Identical adjacent samples cancel each other out, so only changing signals make it out. The more rapidly the signal changes, the more amplitude it will have. This creates a high pass filter. DC is effectively removed, or more accurately, restored to 0.
Questions for the reader, and MOVING THIS DISCUSSION TO PD-OT, These examples make for weird filters. In the real world, nobody makes filters this simplistically. For example: frequencies at half the sample rate are nulled.
#N canvas 267 156 601 603 12; #X obj 63 182 osc~ 440; #X floatatom 63 155 6 0 0 0 - - -; #X obj 37 403 dac~; #X floatatom 92 404 6 0 0 0 - - -; #X obj 92 261 z~; #X obj 63 130 * 40; #X obj 66 110 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144 -1 -1 0 1; #X obj 65 336 *~ 0.25; #X obj 326 337 snapshot~; #X floatatom 326 362 8 0 0 0 - - -; #X obj 326 189 loadbang; #X msg 335 213 ; pd dsp 1; #X obj 326 253 metro 200; #X obj 64 297 -~; #X text 124 252 From zexy , samplewise delay; #X text 396 355 instantaneous sample value; #X text 57 56 Oscillator frequency; #X text 62 91 0; #X text 171 92 127; #X obj 278 137 sig~; #X floatatom 278 108 5 0 1 0 - - -; #X obj 92 375 env~ 2048; #X text 59 77 DC; #X text 275 68 Make your own DC (set oscillator to 0 first); #X text 53 11 Cheap high pass filter.; #X connect 0 0 4 0; #X connect 0 0 13 0; #X connect 1 0 0 0; #X connect 4 0 13 1; #X connect 5 0 1 0; #X connect 6 0 5 0; #X connect 7 0 2 0; #X connect 7 0 2 1; #X connect 7 0 21 0; #X connect 8 0 9 0; #X connect 8 0 9 0; #X connect 10 0 11 0; #X connect 10 0 12 0; #X connect 12 0 8 0; #X connect 13 0 7 0; #X connect 13 0 8 0; #X connect 19 0 13 0; #X connect 19 0 4 0; #X connect 20 0 19 0; #X connect 21 0 3 0;