Building a windowed sinc filter

As promised, here’s our windowed sinc calculator for building a 2x oversampling filter:

 Factor
 Length
 Rejection

 Gain

Notes:

  • Use the Tab or Enter keys to effect changes (most browsers), or press Calculate.
  • The frequency axis is in multiples of the Nyquist frequency.
  • This page is designed specifically to generate and view filters for the current sample rate doubling tutorial, hence the view of 0.50 of the original sample rate with folded frequency components and default gain value. However, you can use it to generate an arbitrary windowed-sinc lowpass. (The folded frequency components in the lower view are there to help you keep an eye on the results—they are not alias components at this point.)
  • For example, a 2x upsampling filter: Set Rejection to the stop-band rejection is dB. Set Length to the number of taps you want to use (more taps for a steeper filter, but higher processing cost). Set Factor to a value less than 0.5, but as close to 0.5 as possible in order to get the maxmimum bandwidth while avoiding foldback (aliasing). Set Gain to 2.
  • Tip: You can copy and paste the coefficients into a text file, and save with an extension of “.csv” if you want to read the values into a spreadsheet for further manipulation.

This entry was posted in Digital Audio, Filters, FIR Filters, Impulse Response, Sample Rate Conversion, Widgets. Bookmark the permalink.

2 Responses to Building a windowed sinc filter

  1. priya says:

    How and where do we use all these values?I want to know, as im still new to DSP and such things

    • Nigel Redmon says:

      Good point—I should do an implementation tutorial for beginners some time. For now, do a web search for information on FIR filters. Implementation is fairly easy—the most difficult part is making sure you have access to the last n samples, where n is the number of coefficients. Then for every new (filtered) output sample, you need to multiply each coefficient by its corresponding sample, and sum that into the total. The basic operation is easy—a single FOR loop, fundamentally—but most of the code work is in buffering the input, and the logic to wrap around the buffer when iterating the filter. Because those details are so implementation-dependent, it’s not simple to show a small code snippet that you can actually use, especially without making assumptions about the reader’s programming experience and language of choice.

Leave a Reply

Your email address will not be published. Required fields are marked *