00001
00013 #ifndef BPMDSP_H__
00014 #define BPMDSP_H__
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <string.h>
00022 #include <math.h>
00023
00024 #include "bpm/bpm_defs.h"
00025 #include "bpm/bpm_messages.h"
00026 #include "bpm/bpm_alloc.h"
00027 #include "bpm/bpm_nr.h"
00028
00029
00030
00031
00032 #define BESSEL 0x00001
00033 #define BUTTERWORTH 0x00002
00034 #define CHEBYSHEV 0x00004
00035 #define RAISEDCOSINE 0x00008
00036 #define RESONATOR 0x00010
00037 #define GAUSSIAN 0x00020
00039 #define BILINEAR_Z_TRANSFORM 0x00100
00040 #define MATCHED_Z_TRANSFORM 0x00200
00041 #define NO_PREWARP 0x00400
00043 #define LOWPASS 0x01000
00044 #define HIGHPASS 0x02000
00045 #define BANDPASS 0x04000
00046 #define BANDSTOP 0x08000
00047 #define NOTCH 0x08000
00048 #define ALLPASS 0x10000
00050 #define MAXORDER 10
00051 #define MAXPZ 2*MAXORDER
00052 #define FILT_EPS 1.0e-10
00053 #define MAX_RESONATOR_ITER 50
00055
00056
00057
00058 #ifdef __cplusplus
00059 extern "C" {
00060 #endif
00061
00065 typedef struct {
00066 int npoles;
00067 int nzeros;
00068 complex_t pole[MAXPZ];
00069 complex_t zero[MAXPZ];
00070 } filterrep_t;
00071
00075 typedef struct {
00076 char name[80];
00078 unsigned int options;
00079 int order;
00081 double fs;
00082 double f1;
00083 double f2;
00085 double alpha1;
00086 double alpha2;
00088 double w_alpha1;
00089 double w_alpha2;
00091 double cheb_ripple;
00092 double Q;
00094 complex_t dc_gain;
00095 complex_t fc_gain;
00096 complex_t hf_gain;
00097 double gain;
00099 filterrep_t *cplane;
00101 int IsFIR;
00102 int nxc;
00103 double xc[MAXPZ+1];
00104 int nyc;
00105 double yc[MAXPZ+1];
00107 double xv[MAXPZ+1];
00108 double yv[MAXPZ+1];
00110 int ns;
00111 double *wfbuffer;
00113 } filter_t;
00114
00115
00116
00117
00118
00119
00136 EXTERN filter_t* create_filter( char name[], unsigned int options, int order,
00137 int ns, double fs, double f1, double f2, double par );
00138
00150 EXTERN int apply_filter( filter_t *f, double *wf );
00151
00152
00159 EXTERN void print_filter( FILE *of, filter_t *f );
00160
00166 EXTERN void delete_filter( filter_t *f );
00167
00168
00178 EXTERN int filter_step_response( filter_t *f, double *wf, int itrig );
00179
00189 EXTERN int filter_impulse_response( filter_t *f, double *wf, int itrig );
00190
00191
00192
00203 EXTERN filterrep_t* create_splane_representation( filter_t *f );
00204
00205
00215 EXTERN filterrep_t* create_resonator_representation( filter_t *f );
00216
00227 EXTERN filterrep_t* zplane_transform( filter_t *f, filterrep_t *s );
00228
00229
00236 EXTERN void print_filter_representation( FILE* of, filterrep_t *r );
00237
00238
00245 EXTERN int normalise_filter( filter_t *f, filterrep_t *s );
00246
00247
00259 EXTERN int calculate_filter_coefficients( filter_t *f );
00260
00261
00269 EXTERN int _expand_complex_polynomial( complex_t *w, int n, complex_t *a );
00270
00278 EXTERN complex_t _eval_complex_polynomial( complex_t *a, int n, complex_t z );
00279
00280 #ifdef __cplusplus
00281 }
00282 #endif
00283
00284 #endif
00285
00286
00287