We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

FIR Filter: Difference between revisions

From SnesLab
Jump to: navigation, search
(Mathematical Definition (testing formulas))
Line 6: Line 6:


== Mathematical Definition ==
== Mathematical Definition ==
<math>y[n] = \sum_{i=0}^{N}b_{i} \cdot x[n-i]</math>
The FIR filter can be defined in the following mathematical formula:
<math>y[n] = \sum_{i=0}^{N-1}b_{i} \cdot x[n-i]</math>
 
For the current output sample Y[n], take the sum of previous N samples from source (including current), multiplied by the FIR coefficient, which in other words is:
 
<math>y[n] = b_{0} \cdot x[n] + b_{1} \cdot x[n-1] + b_{2} \cdot x[n-2] + ... + b_{N-1} \cdot x[n-N-1]</math>
 
 
The SNES has eight FIR taps, which limits N to 8:
 
<math>y[n] = \sum_{i=0}^{7}b_{i} \cdot x[n-i]</math>
 
However, the samples are processed from the oldest to the newest sample. That means for the first FIR tap is applied to the oldest sample while the 8th tap is applied to the newest sample:
 
<math>y[n] = \sum_{i=0}^{7}b_{i} \cdot x[n-(7-i)]</math>
 
Which in other words, it yields to the equivalent pseudo-code:
 
<pre>
y[n] = FIR[0] * x[n - 7] +
      FIR[1] * x[n - 6] +
      FIR[2] * x[n - 5] +
      FIR[3] * x[n - 4] +
      FIR[4] * x[n - 3] +
      FIR[5] * x[n - 2] +
      FIR[6] * x[n - 1] +
      FIR[7] * x[n - 0];
</pre>
 
Where FIR is a array containing the eight taps.


== External links ==
== External links ==
* [https://dspguru.com/dsp/faqs/fir/ FIR filter FAQ - dspGuru]
* [https://dspguru.com/dsp/faqs/fir/ FIR filter FAQ - dspGuru]

Revision as of 04:01, 16 November 2019

FIR Filter (Finite impulse response filter) is a type of filter used on signal processing. It works by taking the sum of last Nth samples multiplied by a value, called FIR taps. It's finite because if you pass a FIR filter in an impulse response, the impulse will fade out after passing the N filter taps. That's easy to notice since the FIR filter never uses itself as feed unlike the IIR Filter.

On the SNES, the FIR filter is used together Echo feedback to determine how echo will reverb back to the echo buffer, with total 8 taps which a 8-bit 1.7 fixed point values.

The S-DSP echo has a buffer which the samples are stored and works like a FIFO: after 8*EDL milliseconds, the samples are played back multiplied by the echo volume. Once these samples have been played, they are inserted back to the buffer but before multiplied by the echo feedback and by the FIR filter to determine how much it will attenuate, allowing to the echo reverb to the buffer with some effects. This however implies that on the SNES, if the echo feedback and the DC gain of the FIR filter is large enough, the samples will stay indefinitely on the buffer and will likely result into signal overflow.

Mathematical Definition

The FIR filter can be defined in the following mathematical formula:

For the current output sample Y[n], take the sum of previous N samples from source (including current), multiplied by the FIR coefficient, which in other words is:


The SNES has eight FIR taps, which limits N to 8:

However, the samples are processed from the oldest to the newest sample. That means for the first FIR tap is applied to the oldest sample while the 8th tap is applied to the newest sample:

Which in other words, it yields to the equivalent pseudo-code:

y[n] = FIR[0] * x[n - 7] +
       FIR[1] * x[n - 6] +
       FIR[2] * x[n - 5] +
       FIR[3] * x[n - 4] +
       FIR[4] * x[n - 3] +
       FIR[5] * x[n - 2] + 
       FIR[6] * x[n - 1] + 
       FIR[7] * x[n - 0];

Where FIR is a array containing the eight taps.

External links