Last active
December 20, 2017 21:29
-
-
Save superctr/b804c255d3f6a27efe9d8c82441c6069 to your computer and use it in GitHub Desktop.
IIR low pass cutoff calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Calculate filter constant for a single pole low pass IIR filter | |
given cut off freq and the sample rate. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
int main(int argc,char *argv[]) | |
{ | |
if(argc<2) | |
{ | |
printf("usage:f1,f2\n"); | |
return -1; | |
} | |
double cutoff = strtof(argv[1],NULL); | |
double rate = strtof(argv[2],NULL); | |
double omega_c = 2*M_PI*(cutoff/rate); | |
double b = 2 - cos(omega_c) - sqrt(pow(2-cos(omega_c),2)-1); | |
printf("b = %.15g\n",b); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment