You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/filters.rst
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,10 @@ You may think we only care about digital filters; this textbook explores DSP, af
27
27
28
28
In DSP, where the input and output are signals, a filter has one input signal and one output signal:
29
29
30
+
.. raw:: html
31
+
32
+
<divstyle="max-width: 700px; margin: 0auto;">
33
+
30
34
.. tikz:: [font=\sffamily\Large, scale=2]
31
35
\definecolor{babyblueeyes}{rgb}{0.36, 0.61, 0.83}
32
36
\node [draw,
@@ -36,9 +40,13 @@ In DSP, where the input and output are signals, a filter has one input signal an
36
40
minimum height=2.4cm
37
41
] (filter) {Filter};
38
42
\draw[<-, very thick] (filter.west) -- ++(-2,0) node[left,align=center]{Input\\(time domain)} ;
39
-
\draw[->, very thick] (filter.east) -- ++(2,0) node[right,align=center]{Output\\(time domain)};
43
+
\draw[->, very thick] (filter.east) -- ++(2,0) node[right,align=center]{Output\\(time domain)};
40
44
:libs: positioning
41
-
:xscale: 80
45
+
:xscale: 100
46
+
47
+
.. raw:: html
48
+
49
+
</div>
42
50
43
51
You cannot feed two different signals into a single filter without adding them together first or doing some other operation. Likewise, the output will always be one signal, i.e., a 1D array of numbers.
44
52
@@ -53,7 +61,7 @@ There are four basic types of filters: low-pass, high-pass, band-pass, and band-
The filter I showed you had real taps, but taps can also be complex. Whether the taps are real or complex doesn't have to match the signal you put through it, i.e., you can put a complex signal through a filter with real taps and vice versa. When the taps are real, the filter's frequency response will be symmetrical around DC (0 Hz). Typically we use complex taps when we need asymmetry, which does not happen too often.
As an example of complex taps, let's go back to the filtering use-case, except this time we want to receive the other interfering signal (without having to re-tune the radio). That means we want a band-pass filter, but not a symmetrical one. We only want to keep (a.k.a "pass") frequencies between around 7 kHz to 13 kHz (we don't want to also pass -13 kHz to -7 kHz):
270
287
@@ -756,7 +773,7 @@ You will learn a lot more about pulse shaping, including some special properties
756
773
Filtering in Chunks
757
774
*******************
758
775
759
-
So far we have filtered signals that fit comfortably in memory: we hand the whole array to :code:`np.convolve` and get the whole result back. But what happens when the signal is enormous, say a recording that is tens of gigabytes, or when the signal needs to be processed in realtime? We need a way to filter the signal a piece at a time, while producing the exact same output we would have gotten if we had filtered it all at once.
776
+
So far we have filtered signals that fit comfortably in memory: we hand the whole array to :code:`np.convolve` and get the whole result back. But what happens when the signal is enormous, say a recording that is tens of gigabytes, or when the signal needs to be processed in real-time? We need a way to filter the signal a piece at a time, while producing the exact same output we would have gotten if we had filtered it all at once.
760
777
761
778
At first this sounds trivial, just filter each chunk and stitch the outputs together. But try it and you will see glitches at every chunk boundary. The reason comes straight from how an FIR filter works: to compute one output sample, the filter reaches back across the previous :math:`M-1` input samples, where :math:`M` is the number of taps. Right at the start of a new chunk, those previous samples live in the *previous* chunk, which we already threw away. So the first :math:`M-1` outputs of every chunk are wrong, because the filter had nothing but zeros to reach back into. Put simply, an FIR filter has *memory*, and if we filter chunk by chunk we have to carry that memory across the seams.
0 commit comments