1 /* 2 * SpanDSP - a series of DSP components for telephony 3 * 4 * complex_filters.h 5 * 6 * Written by Steve Underwood <steveu@coppice.org> 7 * 8 * Copyright (C) 2003 Steve Underwood 9 * 10 * All rights reserved. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License version 2.1, 14 * as published by the Free Software Foundation. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this program; if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 */ 25 26 #if !defined(_SPANDSP_COMPLEX_FILTERS_H_) 27 #define _SPANDSP_COMPLEX_FILTERS_H_ 28 29 typedef struct filter_s filter_t; 30 31 typedef float (*filter_step_func_t)(filter_t *fi, float x); 32 33 /*! Filter state */ 34 typedef struct 35 { 36 int nz; 37 int np; 38 filter_step_func_t fsf; 39 } fspec_t; 40 41 struct filter_s 42 { 43 fspec_t *fs; 44 float sum; 45 int ptr; /* Only for moving average filters */ 46 float v[]; 47 }; 48 49 typedef struct 50 { 51 filter_t *ref; 52 filter_t *imf; 53 } cfilter_t; 54 55 #if defined(__cplusplus) 56 extern "C" 57 { 58 #endif 59 60 SPAN_DECLARE(filter_t *) filter_create(fspec_t *fs); 61 SPAN_DECLARE(void) filter_delete(filter_t *fi); 62 SPAN_DECLARE(float) filter_step(filter_t *fi, float x); 63 64 SPAN_DECLARE(cfilter_t *) cfilter_create(fspec_t *fs); 65 SPAN_DECLARE(void) cfilter_delete(cfilter_t *cfi); 66 SPAN_DECLARE(complexf_t) cfilter_step(cfilter_t *cfi, const complexf_t *z); 67 68 #if defined(__cplusplus) 69 } 70 #endif 71 72 #endif 73 /*- End of file ------------------------------------------------------------*/ 74