aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2018-03-05 13:59:32 +0000
committerymherklotz <ymherklotz@gmail.com>2018-03-05 13:59:32 +0000
commit7ef87f083794e74fbdf4f1fe26b2331fd6ac8fc5 (patch)
tree8645bad7b22b1e1f0b5f28cbf19ba6b7bae53b3a
parentc394d751491782dfe485b0929c0e1343674872f4 (diff)
downloadNoiseSilencer-7ef87f083794e74fbdf4f1fe26b2331fd6ac8fc5.tar.gz
NoiseSilencer-7ef87f083794e74fbdf4f1fe26b2331fd6ac8fc5.zip
finished lab 6
-rw-r--r--Project/RTDSP/.launches/RTDSP.launch2
-rw-r--r--Project/RTDSP/frame.c48
-rw-r--r--Project/TestCode/dft.c2
3 files changed, 44 insertions, 8 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="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
<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="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;modules&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Fri Jan 19 14:07:28 GMT 2018&quot; time_long=&quot;1516370848357&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Jan 23 11:15:11 GMT 2018&quot; time_long=&quot;1516706111426&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 01 11:44:21 GMT 2018&quot; time_long=&quot;1517485461898&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 15 13:55:55 GMT 2018&quot; time_long=&quot;1518702955359&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Feb 27 12:18:55 GMT 2018&quot; time_long=&quot;1519733935329&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 01 13:36:20 GMT 2018&quot; time_long=&quot;1519911380476&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Mon Mar 05 11:30:19 GMT 2018&quot; time_long=&quot;1520249419272&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Mon Mar 05 13:00:55 GMT 2018&quot; time_long=&quot;1520254855612&quot;/&gt;&#13;&#10;&lt;/modules&gt;&#13;&#10;"/>
+<stringAttribute key="com.ti.ccstudio.debug.core.MRU_MODULES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;modules&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Fri Jan 19 14:07:28 GMT 2018&quot; time_long=&quot;1516370848357&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Jan 23 11:15:11 GMT 2018&quot; time_long=&quot;1516706111426&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 01 11:44:21 GMT 2018&quot; time_long=&quot;1517485461898&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 15 13:55:55 GMT 2018&quot; time_long=&quot;1518702955359&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Feb 27 12:18:55 GMT 2018&quot; time_long=&quot;1519733935329&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 01 13:36:20 GMT 2018&quot; time_long=&quot;1519911380476&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Mon Mar 05 11:30:19 GMT 2018&quot; time_long=&quot;1520249419272&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Mon Mar 05 13:58:05 GMT 2018&quot; time_long=&quot;1520258285808&quot;/&gt;&#13;&#10;&lt;/modules&gt;&#13;&#10;"/>
<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="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
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);
+}
diff --git a/Project/TestCode/dft.c b/Project/TestCode/dft.c
index d0dca12..6512c4a 100644
--- a/Project/TestCode/dft.c
+++ b/Project/TestCode/dft.c
@@ -41,7 +41,7 @@ void idft(int N, Complex *X) {
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] /= N;
+ X[n].r /= N;
}
}