Understanding the low-pass/high-pass filter in the tutorial

Mehran_Ziadloo: <p>Following the examples provided in the <a href="https://pytorch.org/audio/stable/tutorials/streamreader_advanced_tutorial.html#highpass-lowpass-filter" rel="noopener nofollow ugc">tutorials</a>, I’m trying to make sense of the low-pass and high-pass filters. I mean, they are very simple filters. And I wasn’t expecting to ask such questions myself, But looking at the results, it makes me wonder if I’m missing something.</p>
<p>The provided example filter is like this:</p>
<pre><code class="lang-auto">filter_desc: aresample=8000,highpass=f=200,lowpass=f=1000,aformat=sample_fmts=fltp
</code></pre>
<p>Which means only frequencies between 200Hz up to 1000Hz shall pass and the rest should be filtered out. But looking at the spectrogram:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/3/d/3d7357e20e74c431df9a42591cc0a3a9ff49a70c.jpeg" alt="image" data-base62-sha1="8LCflDe9jdzltdcKkUR73EenDJy" width="640" height="480"></p>
<p>There are still information lower and 200Hz as well as above 1000Hz. What am I missing here?</p>
<p>For clarification, this is what I was expecting to see:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/7/7700f47b1f793558f65a10bb8e705fe2c6298347.png" data-download-href="https://discuss.pytorch.org/uploads/default/7700f47b1f793558f65a10bb8e705fe2c6298347" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/7/7700f47b1f793558f65a10bb8e705fe2c6298347_2_690x269.png" alt="image" data-base62-sha1="gYKRDkgKOseS3PW3fztNqbJGZhl" width="690" height="269" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/7/7700f47b1f793558f65a10bb8e705fe2c6298347_2_690x269.png, https://discuss.pytorch.org/uploads/default/original/3X/7/7/7700f47b1f793558f65a10bb8e705fe2c6298347.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/7/7/7700f47b1f793558f65a10bb8e705fe2c6298347.png 2x" data-dominant-color="7F839B"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">769×300 47.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>Your desired result would correspond to an “ideal” box filter, which has a <code>sinc</code> impulse response in the time domain. I don’t know which filters are used in your application, but note that each one has a different response. E.g. take a look at the <a href="https://en.wikipedia.org/wiki/Low-pass_filter#/media/File:Butterworth_response.svg">butterworth filter response</a>:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/7/f7ceb1d46533b744f4d6091a707f79e988f25423.png" data-download-href="https://discuss.pytorch.org/uploads/default/f7ceb1d46533b744f4d6091a707f79e988f25423" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/f/7/f7ceb1d46533b744f4d6091a707f79e988f25423_2_666x500.png" alt="image" data-base62-sha1="zmcM8DpfXwsSkMIAj1ZEJNsard1" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/f/7/f7ceb1d46533b744f4d6091a707f79e988f25423_2_666x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/f/7/f7ceb1d46533b744f4d6091a707f79e988f25423_2_999x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/f/7/f7ceb1d46533b744f4d6091a707f79e988f25423.png 2x" data-dominant-color="553F43"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1280×960 43.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>which shows the gain in <code>dB</code>.<br>
I would also assume that you are plotting the power spectral density in the frequency domain and thus the values and color mapping also corresponds to a <code>dB</code> scale?<br>
If so, the filtering looks reasonable.</p>