diff options
author | ymherklotz <ymherklotz@gmail.com> | 2018-03-05 16:57:05 +0000 |
---|---|---|
committer | ymherklotz <ymherklotz@gmail.com> | 2018-03-05 16:57:05 +0000 |
commit | fd66f91b4b04f45a9c36864f73988b8881ce7692 (patch) | |
tree | ac63489606f670aeee4d86f6a847b4cb21c5ff30 | |
parent | df2686e4510b8c801dc075a72c3a936e313e6086 (diff) | |
download | NoiseSilencer-fd66f91b4b04f45a9c36864f73988b8881ce7692.tar.gz NoiseSilencer-fd66f91b4b04f45a9c36864f73988b8881ce7692.zip |
Finished without enhancementsgit push
-rw-r--r-- | Project/RTDSP/.launches/RTDSP.launch | 2 | ||||
-rw-r--r-- | Project/RTDSP/enhance.c | 22 |
2 files changed, 21 insertions, 3 deletions
diff --git a/Project/RTDSP/.launches/RTDSP.launch b/Project/RTDSP/.launches/RTDSP.launch index aa617ce..2a31782 100644 --- a/Project/RTDSP/.launches/RTDSP.launch +++ b/Project/RTDSP/.launches/RTDSP.launch @@ -13,7 +13,7 @@ <stringAttribute key="CCEDebugOptions.TARGET_CONFIGURATION_OPTION" value="full"/> <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8"?> <memoryBlockExpressionList/> "/> <stringAttribute key="com.ti.ccstudio.debug.core.MRU_PROGRAM_NAME" value="C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out"/> -<stringAttribute key="com.ti.ccstudio.debug.core.MRU_MODULES" value="<?xml version="1.0" encoding="UTF-8"?> <modules> <module name="C:\GIT\RTDSP\lab3\RTDSP\Debug\RTDSP.out" time="Fri Jan 19 14:07:28 GMT 2018" time_long="1516370848357"/> <module name="C:\Github\RTDSP\lab3\RTDSP\Debug\RTDSP.out" time="Tue Jan 23 11:15:11 GMT 2018" time_long="1516706111426"/> <module name="C:\GIT\RTDSP\lab4\RTDSP\Debug\RTDSP.out" time="Thu Feb 01 11:44:21 GMT 2018" time_long="1517485461898"/> <module name="C:\github\RTDSP\lab4\RTDSP\Debug\RTDSP.out" time="Thu Feb 15 13:55:55 GMT 2018" time_long="1518702955359"/> <module name="C:\Github\RTDSP\lab5\RTDSP\Debug\RTDSP.out" time="Tue Feb 27 12:18:55 GMT 2018" time_long="1519733935329"/> <module name="C:\github\RTDSP\lab5\RTDSP\Debug\RTDSP.out" time="Thu Mar 01 13:36:20 GMT 2018" time_long="1519911380476"/> <module name="C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Mon Mar 05 11:30:19 GMT 2018" time_long="1520249419272"/> <module name="C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Mon Mar 05 16:12:26 GMT 2018" time_long="1520266346318"/> </modules> "/> +<stringAttribute key="com.ti.ccstudio.debug.core.MRU_MODULES" value="<?xml version="1.0" encoding="UTF-8"?> <modules> <module name="C:\GIT\RTDSP\lab3\RTDSP\Debug\RTDSP.out" time="Fri Jan 19 14:07:28 GMT 2018" time_long="1516370848357"/> <module name="C:\Github\RTDSP\lab3\RTDSP\Debug\RTDSP.out" time="Tue Jan 23 11:15:11 GMT 2018" time_long="1516706111426"/> <module name="C:\GIT\RTDSP\lab4\RTDSP\Debug\RTDSP.out" time="Thu Feb 01 11:44:21 GMT 2018" time_long="1517485461898"/> <module name="C:\github\RTDSP\lab4\RTDSP\Debug\RTDSP.out" time="Thu Feb 15 13:55:55 GMT 2018" time_long="1518702955359"/> <module name="C:\Github\RTDSP\lab5\RTDSP\Debug\RTDSP.out" time="Tue Feb 27 12:18:55 GMT 2018" time_long="1519733935329"/> <module name="C:\github\RTDSP\lab5\RTDSP\Debug\RTDSP.out" time="Thu Mar 01 13:36:20 GMT 2018" time_long="1519911380476"/> <module name="C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Mon Mar 05 11:30:19 GMT 2018" time_long="1520249419272"/> <module name="C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Mon Mar 05 16:51:28 GMT 2018" time_long="1520268688442"/> </modules> "/> <stringAttribute key="CCEDebugOptions.CPU_NAME" value="Spectrum Digital DSK-EVM-eZdsp onboard USB Emulator_0/TMS320C671X"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RTDSP"/> <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8"?> <globalVariableList/> "/> diff --git a/Project/RTDSP/enhance.c b/Project/RTDSP/enhance.c index fc058fe..0ee84ff 100644 --- a/Project/RTDSP/enhance.c +++ b/Project/RTDSP/enhance.c @@ -94,9 +94,12 @@ float *inwin, *outwin; /* Input and output windows */ float ingain, outgain; /* ADC and DAC gains */ float cpufrac; /* Fraction of CPU time used */ complex *fft_out; /* FFT output */ +complex* noise; volatile int io_ptr=0; /* Input/ouput pointer for circular buffers */ volatile int frame_ptr=0; /* Frame pointer */ volatile int frame_ctr =0; +volatile float lambda = 0.05; +volatile float alpha = 20; double avg = 0; Spectrum M[NUM_M]; /******************************* Function prototypes *******************************/ @@ -194,6 +197,8 @@ void process_frame(void) { int k, m; int io_ptr0; + int min_index; + float min_avg = MAX_FLOAT, mag_N_X; avg = 0; /* work out fraction of available CPU time used by algorithm */ cpufrac = ((float) (io_ptr & (FRAMEINC - 1)))/FRAMEINC; @@ -238,8 +243,21 @@ void process_frame(void) } } - for(k = 0; k < FFTLEN; ++k) { - fft_out[k] = M[0].spec[k]; + for(k = 0; k < NUM_M; ++k) { + if (M[k].mag_avg < min_avg) { + min_avg = M[k].mag_avg; + min_index = k; + } + } + + noise = M[min_index].spec; + + for (k = 0; k < FFTLEN; ++k) { + float g; + mag_N_X = 1 - cabs(noise[k])/cabs(fft_out[k]); + g = mag_N_X > lambda ? mag_N_X : lambda; + fft_out[k].r *= g; + fft_out[k].i *= g; } ifft(FFTLEN, fft_out); |