Skip to content

Commit

Permalink
Document FIR filter requirements, fixes #114
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed Feb 7, 2016
1 parent a25efdf commit 29b4ded
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/Effects/Filter_FIR/Filter_FIR.ino
Expand Up @@ -62,7 +62,7 @@ AudioControlSGTL5000 audioShield;

struct fir_filter {
short *coeffs;
short num_coeffs;
short num_coeffs; // num_coeffs must be an even number, 4 or higher
};

// index of current filter. Start with the low pass.
Expand Down
7 changes: 5 additions & 2 deletions filter_fir.h
Expand Up @@ -41,8 +41,11 @@ class AudioFilterFIR : public AudioStream
coeff_p = cp;
// Initialize FIR instance (ARM DSP Math Library)
if (coeff_p && (coeff_p != FIR_PASSTHRU) && n_coeffs <= FIR_MAX_COEFFS) {
arm_fir_init_q15(&fir_inst, n_coeffs, (q15_t *)coeff_p,
&StateQ15[0], AUDIO_BLOCK_SAMPLES);
if (arm_fir_init_q15(&fir_inst, n_coeffs, (q15_t *)coeff_p,
&StateQ15[0], AUDIO_BLOCK_SAMPLES) != ARM_MATH_SUCCESS) {
// n_coeffs must be an even number, 4 or larger
coeff_p = NULL;
}
}
}
void end(void) {
Expand Down
12 changes: 12 additions & 0 deletions gui/index.html
Expand Up @@ -2218,6 +2218,18 @@ <h3>Functions</h3>
<h3>Examples</h3>
<p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter_FIR
</p>
<h3>Known Issues</h3>
<p>Your filter's impulse response array must have an even length. If you have
add odd number of taps, you must add an extra zero to increase the length
to an even number.
</p>
<p>The minimum number of taps is 4. If you use less, add extra zeros to increase
the length to 4.
</p>
<p>The impulse response must be given in reverse order. Many filters have
symetrical impluse response, making this a non-issue. If your filter has
a non-symetrical response, make sure the data is in reverse time order.
</p>
<h3>Notes</h3>
<p>FIR filters requires more CPU time than Biquad (IIR), but they can
implement filters with better phase response.
Expand Down

0 comments on commit 29b4ded

Please sign in to comment.