diff options
author | ymherklotz <ymherklotz@gmail.com> | 2018-03-05 13:59:32 +0000 |
---|---|---|
committer | ymherklotz <ymherklotz@gmail.com> | 2018-03-05 13:59:32 +0000 |
commit | 7ef87f083794e74fbdf4f1fe26b2331fd6ac8fc5 (patch) | |
tree | 8645bad7b22b1e1f0b5f28cbf19ba6b7bae53b3a /Project/RTDSP | |
parent | c394d751491782dfe485b0929c0e1343674872f4 (diff) | |
download | NoiseSilencer-7ef87f083794e74fbdf4f1fe26b2331fd6ac8fc5.tar.gz NoiseSilencer-7ef87f083794e74fbdf4f1fe26b2331fd6ac8fc5.zip |
finished lab 6
Diffstat (limited to 'Project/RTDSP')
-rw-r--r-- | Project/RTDSP/.launches/RTDSP.launch | 2 | ||||
-rw-r--r-- | Project/RTDSP/frame.c | 48 |
2 files changed, 43 insertions, 7 deletions
diff --git a/Project/RTDSP/.launches/RTDSP.launch b/Project/RTDSP/.launches/RTDSP.launch index 3649b06..6a5779e 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 13:00:55 GMT 2018" time_long="1520254855612"/> </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 13:58:05 GMT 2018" time_long="1520258285808"/> </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/frame.c b/Project/RTDSP/frame.c index ea1287b..4c9954c 100644 --- a/Project/RTDSP/frame.c +++ b/Project/RTDSP/frame.c @@ -36,7 +36,7 @@ /* Some functions to help with Complex algebra and FFT. */ #include "cmplx.h" -#include "fft_functions.h" +#include "fft_functions.h" // Some functions to help with writing/reading the audio ports when using interrupts. #include <helper_functions_ISR.h> @@ -67,10 +67,10 @@ DSK6713_AIC23_Config Config = { \ // Codec handle:- a variable used to identify audio interface DSK6713_AIC23_CodecHandle H_Codec; -// PI defined here for use in your code -#define PI 3.141592653589793 +// PI defined here for use in your code +#define E_PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062 -#define BUFLEN 128 /* Frame buffer length must be even for real fft */ +#define BUFLEN 800 /* Frame buffer length must be even for real fft */ /* Pointers to data buffers */ @@ -88,6 +88,8 @@ void init_HWI(void); void ISR_AIC(void); void init_arrays(void); void wait_buffer(void); +void dft_(int N, complex *X); +void idft_(int N, complex *X); /********************************** Main routine ************************************/ void main() @@ -202,14 +204,14 @@ void wait_buffer(void) C[i].r = intermediate[i]; } - fft(BUFLEN, C); + dft_(BUFLEN, C); // Calculate the magnitude of the complex numbers for (i = 0; i < BUFLEN; ++i) { mag[i] = cabs(C[i]); } - ifft(BUFLEN, C); + idft_(BUFLEN, C); for (i = 0; i < BUFLEN; ++i) { intermediate[i] = C[i].r; } @@ -221,4 +223,38 @@ void wait_buffer(void) } +void dft_(int N, complex *X) { + int i, n, k; + complex* x = malloc(N*sizeof(X[0])); + for(i = 0; i < N; ++i) { + x[i] = X[i]; + } + for(k = 0; k < N; ++k) { + X[k].r = 0.f; + X[k].i = 0.f; + for(n = 0; n < N; ++n) { + X[k].r += x[n].r * cos(2 * E_PI * k * n / N); + X[k].i -= x[n].r * sin(2 * E_PI * k * n / N); + } + } + + free(x); +} +void idft_(int N, complex *X) { + int i, n, k; + complex* x = malloc(N*sizeof(X[0])); + for(i = 0; i < N; ++i) { + x[i] = X[i]; + } + for(n = 0; n < N; ++n) { + X[n].i = 0.f; + X[n].r = 0.f; + for(k = 0; k < N; ++k) { + X[n].r += x[k].r * cos(2 * E_PI * k * n / N) - x[k].i * sin(2 * E_PI * k * n / N); + } + X[n].r /= N; + } + + free(x); +} |