Created
February 15, 2023 13:03
-
-
Save harieamjari/5ba664699cf9734f2824145e64433761 to your computer and use it in GitHub Desktop.
Notch filter transfer function
This file contains hidden or 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
/* Notch filter at 10000Hz */ | |
#include <stdio.h> | |
#include <complex.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <assert.h> | |
int main(int argc, char *argv[]){ | |
assert(argc == 2); | |
float complex e = M_E; | |
float sample = 32.0; | |
float rp = 2.0*M_PI*10000.0/44100.0; | |
float deg = 2.0*M_PI/44100.0; | |
float con = 1.0; | |
float complex r = con*cpowf(e, I*rp); | |
float complex p = con*cpowf(e, I*rp)*0.95; | |
for (int i = 0; i < 32*44100; i++){ | |
float magr = cabsf(con*cpowf(e, I*deg*(float)i/sample) - r); | |
float magp = cabsf(con*cpowf(e, I*deg*(float)i/sample) - p); | |
printf("%f %f\n", (float)i/sample, magr/magp ); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment