Skip to content

Commit

Permalink
Included Bandpass filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Gravillon committed Jul 29, 2023
1 parent b0ad467 commit 6aaac04
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 13 deletions.
Binary file added doc24652.pdf
Binary file not shown.
43 changes: 39 additions & 4 deletions filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,49 @@ ChebFilter* create_che_filter(int NP, double PR, int LH, double FC) {
return(filter);
}

ChebFilter* create_bw_low_pass_filter(int NP, double FC) {
return(create_che_filter(NP, 0, 0, FC));
dChebFilter* create_bw_low_pass_filter(int NP, double FC) {
dChebFilter *filter=(dChebFilter*)malloc(sizeof(dChebFilter));

filter->type=0;
filter->lp_filter=create_che_filter(NP, 0, 0, FC);
filter->hp_filter=NULL;

return(filter);
}

ChebFilter* create_bw_high_pass_filter(int NP, double FC) {
return(create_che_filter(NP, 0, 1, FC));
dChebFilter* create_bw_high_pass_filter(int NP, double FC) {
dChebFilter *filter=(dChebFilter*)malloc(sizeof(dChebFilter));

filter->type=1;
filter->lp_filter=NULL;
filter->hp_filter=create_che_filter(NP, 0, 1, FC);

return(filter);
}

dChebFilter* create_bw_bp_pass_filter(int NP, double FC, double winwidth) {
dChebFilter *filter=(dChebFilter*)malloc(sizeof(dChebFilter));

filter->type=2;
filter->lp_filter=create_che_filter(NP, 0, 0, FC*(1.0+fabsl(winwidth)));
filter->hp_filter=create_che_filter(NP, 0, 1, FC*(1.0-fabsl(winwidth)));

return(filter);
}

double applydfilter(dChebFilter* filter, double X0) {
double output=X0;

if(filter->lp_filter!=NULL)
output=applyfilter(filter->lp_filter, output);

if(filter->hp_filter!=NULL)
output=applyfilter(filter->hp_filter, output);

return(output);
}


ChebFilter* create_che_low_pass_filter(int NP, double FC, double PR) {
return(create_che_filter(NP, PR, 0, FC));
}
Expand Down
27 changes: 18 additions & 9 deletions filter.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@

typedef struct filter {
double a[20];
double b[20];
double a[20]; // inputs coefficients
double b[20]; // output coefficients

double X[20];
double Y[20];
double X[20]; // history of inputs
double Y[20]; // history of outputs

int NP;
int NP; // Nomber of Poles - Order

double a0;
double a0; // internal
double a1;
double a2;
double b0;
double b1;
double b2;
} ChebFilter;


typedef struct doublefilter {
int type;
ChebFilter *lp_filter;
ChebFilter *hp_filter;
} dChebFilter;

ChebFilter* call_205(int P, ChebFilter* filter, double FC, int NP, int LH, double PR);

ChebFilter* create_che_filter(int NP, double PR, int LH, double FC);
ChebFilter* create_bw_low_pass_filter(int NP, double FC);

ChebFilter* create_bw_high_pass_filter(int NP, double FC);
ChebFilter* create_che_low_pass_filter(int NP, double FC, double PR);
ChebFilter* create_che_high_pass_filter(int NP, double FC, double PR);


dChebFilter* create_bw_low_pass_filter(int NP, double FC);
dChebFilter* create_bw_high_pass_filter(int NP, double FC);
dChebFilter* create_bw_bp_pass_filter(int NP, double FC, double winwidth);

double applyfilter(ChebFilter* filter, double X0);

0 comments on commit 6aaac04

Please sign in to comment.