diff options
author | unknown <dm2515@eews303a-039.ic.ac.uk> | 2018-03-15 16:06:19 +0000 |
---|---|---|
committer | unknown <dm2515@eews303a-039.ic.ac.uk> | 2018-03-15 16:06:19 +0000 |
commit | 7fc17c1117241acf0d5cc9f9736282519829783a (patch) | |
tree | 13e1bb3f972b5565b9f39f900978c3e3be400254 /Project/RTDSP | |
parent | 2248538707dea4437db32497a518a3a606386a75 (diff) | |
download | NoiseSilencer-7fc17c1117241acf0d5cc9f9736282519829783a.tar.gz NoiseSilencer-7fc17c1117241acf0d5cc9f9736282519829783a.zip |
Adding audio files
Diffstat (limited to 'Project/RTDSP')
20 files changed, 42 insertions, 14 deletions
diff --git a/Project/RTDSP/.launches/RTDSP.launch b/Project/RTDSP/.launches/RTDSP.launch index 486fa5b..8830bf8 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:\GIT\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:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Thu Mar 08 15:31:06 GMT 2018" time_long="1520523066763"/> <module name="C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Thu Mar 08 17:03:11 GMT 2018" time_long="1520528591515"/> </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:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Thu Mar 08 15:31:06 GMT 2018" time_long="1520523066763"/> <module name="C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out" time="Thu Mar 15 16:05:05 GMT 2018" time_long="1521129905593"/> </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/audio/best_case/car.wma b/Project/RTDSP/audio/best_case/car.wma Binary files differnew file mode 100644 index 0000000..30c3302 --- /dev/null +++ b/Project/RTDSP/audio/best_case/car.wma diff --git a/Project/RTDSP/audio/best_case/lynx2.wma b/Project/RTDSP/audio/best_case/lynx2.wma Binary files differnew file mode 100644 index 0000000..1966d2d --- /dev/null +++ b/Project/RTDSP/audio/best_case/lynx2.wma diff --git a/Project/RTDSP/audio/best_case/phantom2.wma b/Project/RTDSP/audio/best_case/phantom2.wma Binary files differnew file mode 100644 index 0000000..733c5e2 --- /dev/null +++ b/Project/RTDSP/audio/best_case/phantom2.wma diff --git a/Project/RTDSP/audio/best_case/phantom4.wma b/Project/RTDSP/audio/best_case/phantom4.wma Binary files differnew file mode 100644 index 0000000..5a7aa75 --- /dev/null +++ b/Project/RTDSP/audio/best_case/phantom4.wma diff --git a/Project/RTDSP/audio/original/car1.wav b/Project/RTDSP/audio/original/car1.wav Binary files differnew file mode 100644 index 0000000..4d64c03 --- /dev/null +++ b/Project/RTDSP/audio/original/car1.wav diff --git a/Project/RTDSP/audio/original/clean.wav b/Project/RTDSP/audio/original/clean.wav Binary files differnew file mode 100644 index 0000000..0a76159 --- /dev/null +++ b/Project/RTDSP/audio/original/clean.wav diff --git a/Project/RTDSP/audio/original/factory1.wav b/Project/RTDSP/audio/original/factory1.wav Binary files differnew file mode 100644 index 0000000..6486e33 --- /dev/null +++ b/Project/RTDSP/audio/original/factory1.wav diff --git a/Project/RTDSP/audio/original/factory2.wav b/Project/RTDSP/audio/original/factory2.wav Binary files differnew file mode 100644 index 0000000..e563084 --- /dev/null +++ b/Project/RTDSP/audio/original/factory2.wav diff --git a/Project/RTDSP/audio/original/lynx1.wav b/Project/RTDSP/audio/original/lynx1.wav Binary files differnew file mode 100644 index 0000000..cb59ce9 --- /dev/null +++ b/Project/RTDSP/audio/original/lynx1.wav diff --git a/Project/RTDSP/audio/original/lynx2.wav b/Project/RTDSP/audio/original/lynx2.wav Binary files differnew file mode 100644 index 0000000..e25915b --- /dev/null +++ b/Project/RTDSP/audio/original/lynx2.wav diff --git a/Project/RTDSP/audio/original/phantom1.wav b/Project/RTDSP/audio/original/phantom1.wav Binary files differnew file mode 100644 index 0000000..4a0637e --- /dev/null +++ b/Project/RTDSP/audio/original/phantom1.wav diff --git a/Project/RTDSP/audio/original/phantom2.wav b/Project/RTDSP/audio/original/phantom2.wav Binary files differnew file mode 100644 index 0000000..5ebf511 --- /dev/null +++ b/Project/RTDSP/audio/original/phantom2.wav diff --git a/Project/RTDSP/audio/original/phantom4.wav b/Project/RTDSP/audio/original/phantom4.wav Binary files differnew file mode 100644 index 0000000..893615b --- /dev/null +++ b/Project/RTDSP/audio/original/phantom4.wav diff --git a/Project/RTDSP/audio/original/signals.txt b/Project/RTDSP/audio/original/signals.txt new file mode 100644 index 0000000..fc1f488 --- /dev/null +++ b/Project/RTDSP/audio/original/signals.txt @@ -0,0 +1,17 @@ +Speech files for testing noise cancellation + +clean.wav A 40-second passage concerning sailors. All other files + have noise added to this passage. The final digit of the + file names indicates the noise amplitude. + +car1.wav Car noise + +factory1.wav Factory Noise at two sound levels +factory2.wav + +lynx1.wav A lynx helicopter +lynx2.wav + +phantom1.wav An F15 fighter aircraft +phantom2.wav +phantom4.wav diff --git a/Project/RTDSP/audio/without_optimisations/car.wma b/Project/RTDSP/audio/without_optimisations/car.wma Binary files differnew file mode 100644 index 0000000..9412a9a --- /dev/null +++ b/Project/RTDSP/audio/without_optimisations/car.wma diff --git a/Project/RTDSP/audio/without_optimisations/factory2.wma b/Project/RTDSP/audio/without_optimisations/factory2.wma Binary files differnew file mode 100644 index 0000000..ddfa200 --- /dev/null +++ b/Project/RTDSP/audio/without_optimisations/factory2.wma diff --git a/Project/RTDSP/audio/without_optimisations/lynx2.wma b/Project/RTDSP/audio/without_optimisations/lynx2.wma Binary files differnew file mode 100644 index 0000000..9d8bf0e --- /dev/null +++ b/Project/RTDSP/audio/without_optimisations/lynx2.wma diff --git a/Project/RTDSP/audio/without_optimisations/phantom4.wma b/Project/RTDSP/audio/without_optimisations/phantom4.wma Binary files differnew file mode 100644 index 0000000..5e22805 --- /dev/null +++ b/Project/RTDSP/audio/without_optimisations/phantom4.wma diff --git a/Project/RTDSP/enhance.c b/Project/RTDSP/enhance.c index 771f873..fc619d1 100644 --- a/Project/RTDSP/enhance.c +++ b/Project/RTDSP/enhance.c @@ -93,16 +93,19 @@ complex *fft_out; /* FFT output */ float *noise; float *power_in; float *mag_in; -float* lpf; +float* p_w; float* prev_noise; float* SNR; volatile int io_ptr=0; /* Input/ouput pointer for circular buffers */ volatile int frame_ptr=0; /* Frame pointer */ volatile int frame_ctr = 0; volatile int m_ptr = 0; +float snr_val = 0; +float total_snr = 0; float lambda = 0.05; -float alpha[NUM_ALPHA] = {1000, 600, 400, 400}; -double avg = 0; +float alpha[NUM_ALPHA] = {300, 400, 600, 1000}; +float avg = 0; +float sum = 0; float *M[NUM_M]; float mag_N_X; float K; @@ -122,7 +125,7 @@ void main() { int k; // used in various for loops - + int counter = 1; /* Initialize and zero fill arrays */ inbuffer = (float *) calloc(CIRCBUF, sizeof(float)); /* Input array */ @@ -133,11 +136,14 @@ void main() outwin = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ fft_out = (complex *) calloc(FFTLEN, sizeof(complex)); /* FFT Output */ power_in = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ - lpf = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ + p_w = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ mag_in = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ noise = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ prev_noise = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ SNR = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */ + for(k = 0; k < FFTLEN; ++k) { + SNR[k] = 0; + } /* initialize board and the audio port */ init_hardware(); @@ -160,7 +166,11 @@ void main() K = exp(-TFRAME/time_constant); /* main loop, wait for interrupt */ - while(1) process_frame(); + while(1) { + process_frame(); + counter++; + snr_val = total_snr / counter; + } } /********************************** init_hardware() *********************************/ @@ -233,17 +243,18 @@ void get_noise(void) { void overestimation(void) { int i; - float sum; - + sum = 0; // Calcualte |signal^2/noise^2| for all k for (i = 0; i < FFTLEN; ++i) { - SNR[i] = power_in[i] / noise[i]; - sum += SNR[i]; + if(noise[i] != 0) { + SNR[i] = power_in[i] / noise[i]; + sum += SNR[i]; + } } // Calculate average sum /= FFTLEN; - + total_snr += sum; // Use SNRs to divide for (i = 0; i < FFTLEN; ++i) { // Normalising @@ -306,7 +317,7 @@ void process_frame(void) power_in[k] = fft_out[k].r * fft_out[k].r + fft_out[k].i * fft_out[k].i; } - low_pass_filter(power_in, lpf); + low_pass_filter(power_in, p_w); low_pass_filter(noise, prev_noise); // Get average of fft_out and write to Spectrum @@ -327,7 +338,7 @@ void process_frame(void) // max(lambda, |N(w)/g(w)| for (k = 0; k < FFTLEN; ++k) { float g; - mag_N_X = 1 - noise[k]/power_in[k]; + mag_N_X = sqrt(1 - noise[k]/power_in[k]); g = mag_N_X > lambda ? mag_N_X : lambda; fft_out[k] = rmul(g, fft_out[k]); } |