2 * Copyright Droids Corporation, Microb Technology, Eirbot (2006)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: biquad.h,v 1.2.2.3 2007-05-23 17:18:13 zer0 Exp $
28 /** this is the biquad structure */
33 int16_t a1, a2; /* never access it directly, use accessors */
36 uint8_t recursive_shift;
43 struct biquad_filter * son;
53 * init sets an unity filter, as usual initialization is absolutely
56 extern void biquad_init (struct biquad_filter * p);
59 extern void biquad_set_numerator_coeffs (struct biquad_filter *p, int16_t b0, int16_t b1, int16_t b2);
60 extern void biquad_set_deniminator_coeffs(struct biquad_filter *p, int16_t a1, int16_t a2);
62 extern void biquad_set_divisor_shifts(struct biquad_filter *p, uint8_t recursive_shift, uint8_t out_shift);
65 * this sets a filter to put in series.
68 * biquad_set_series_son(& filter1, &filter2)
70 * then please use ONLY the filter1. The filter 2 will recursively
71 * be called into the filter 1 function :
72 * output = biquad_do_filter(& filter1, input);
74 * You can put in series as much biquad filters as you want.
76 extern void biquad_set_series_son(struct biquad_filter *p, struct biquad_filter *son);
79 * this is useful for cleaning the filter memories before a new data
82 * With this you avoid having old data in the filter memories when
83 * beginning to filter a new stream. Can also be used after
84 * changing the coefficients, to avoid jumps of the output value.
86 extern void biquad_flush_memories(struct biquad_filter *p);
90 * filter processing, 1 iteration.
91 * This function is not protected against writing in the structure while
92 * execution is ongoing!
94 extern int32_t biquad_do_filter(void * data , int32_t in);