aboutsummaryrefslogtreecommitdiffstats
path: root/lab5
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2018-02-27 11:46:08 +0000
committerymherklotz <ymherklotz@gmail.com>2018-02-27 11:46:08 +0000
commit1551a4b3343e613fe645e519216b590146b1337b (patch)
tree114c629503e67a02a99909a091d00924677893be /lab5
parent505e31b789f4bc0dde0eed952257e5460f788f4e (diff)
downloadNoiseSilencer-1551a4b3343e613fe645e519216b590146b1337b.tar.gz
NoiseSilencer-1551a4b3343e613fe645e519216b590146b1337b.zip
Adding filter
Diffstat (limited to 'lab5')
-rw-r--r--lab5/RTDSP/.launches/RTDSP.launch2
-rw-r--r--lab5/RTDSP/Matlab/coeff.txt2
-rw-r--r--lab5/RTDSP/Matlab/coeff2.txt2
-rw-r--r--lab5/RTDSP/Matlab/filter_coeff_ell_a.txt2
-rw-r--r--lab5/RTDSP/Matlab/filter_coeff_ell_b.txt2
-rw-r--r--lab5/RTDSP/Matlab/gen_filter.m9
-rw-r--r--lab5/RTDSP/intio.c33
7 files changed, 30 insertions, 22 deletions
diff --git a/lab5/RTDSP/.launches/RTDSP.launch b/lab5/RTDSP/.launches/RTDSP.launch
index 3ace42b..086e65e 100644
--- a/lab5/RTDSP/.launches/RTDSP.launch
+++ b/lab5/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\lab5\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 11:05:25 GMT 2018&quot; time_long=&quot;1519729525911&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 11:23:09 GMT 2018&quot; time_long=&quot;1519730589901&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/lab5/RTDSP/Matlab/coeff.txt b/lab5/RTDSP/Matlab/coeff.txt
new file mode 100644
index 0000000..18322f2
--- /dev/null
+++ b/lab5/RTDSP/Matlab/coeff.txt
@@ -0,0 +1,2 @@
+double a[] = {1.000000e+00.32, -3.622738e+00.32, 5.063888e+00.32, -3.234610e+00.32, 7.984165e-01.32, };
+double b[] = {9.75649439330639190000000000000000e-02, -3.42867426997343900000000000000000e-01, 4.91100537962581350000000000000000e-01, -3.42867426997343740000000000000000e-01, 9.75649439330638630000000000000000e-02, }; \ No newline at end of file
diff --git a/lab5/RTDSP/Matlab/coeff2.txt b/lab5/RTDSP/Matlab/coeff2.txt
new file mode 100644
index 0000000..75e0921
--- /dev/null
+++ b/lab5/RTDSP/Matlab/coeff2.txt
@@ -0,0 +1,2 @@
+double a[] = {1.000000000000000e+00, -3.622738280081862e+00, 5.063887790131743e+00, -3.234610259864946e+00, 7.984164681552797e-01, };
+double b[] = {9.756494393306392e-02, -3.428674269973439e-01, 4.911005379625814e-01, -3.428674269973437e-01, 9.756494393306386e-02, }; \ No newline at end of file
diff --git a/lab5/RTDSP/Matlab/filter_coeff_ell_a.txt b/lab5/RTDSP/Matlab/filter_coeff_ell_a.txt
index 385f642..f6d3023 100644
--- a/lab5/RTDSP/Matlab/filter_coeff_ell_a.txt
+++ b/lab5/RTDSP/Matlab/filter_coeff_ell_a.txt
@@ -1 +1 @@
-double a[] = { 1.0000000000000000, -3.8475581971606738, 5.5906851263228337, -3.6360361044752754, 0.89323992595555990 };
+ 1.0000000000000000e+00 -3.6227382800818617e+00 5.0638877901317434e+00 -3.2346102598649464e+00 7.9841646815527967e-01
diff --git a/lab5/RTDSP/Matlab/filter_coeff_ell_b.txt b/lab5/RTDSP/Matlab/filter_coeff_ell_b.txt
index 5d225da..c8c1e48 100644
--- a/lab5/RTDSP/Matlab/filter_coeff_ell_b.txt
+++ b/lab5/RTDSP/Matlab/filter_coeff_ell_b.txt
@@ -1 +1 @@
-double b[] = { 9.6683656064376025e-02, -3.7417971508180198e-01, 5.5502519309909670e-01, -3.7417971508180270e-01, 9.6683656064376386e-02 };
+ 9.7564943933063919e-02 -3.4286742699734390e-01 4.9110053796258135e-01 -3.4286742699734374e-01 9.7564943933063863e-02
diff --git a/lab5/RTDSP/Matlab/gen_filter.m b/lab5/RTDSP/Matlab/gen_filter.m
index d6b5304..618d719 100644
--- a/lab5/RTDSP/Matlab/gen_filter.m
+++ b/lab5/RTDSP/Matlab/gen_filter.m
@@ -2,5 +2,10 @@ Fs = 8000;
[b,a] = elliptical (Fs);
freqz(b, a);
-%save filter_coeff_ell_b.txt b -ASCII -DOUBLE -TABS
-%save filter_coeff_ell_a.txt a -ASCII -DOUBLE -TABS \ No newline at end of file
+fileID = fopen('coeff2.txt','w');
+fprintf(fileID, 'double a[] = {');
+fprintf(fileID, '%.15e, ', a);
+fprintf(fileID, '};\ndouble b[] = {');
+fprintf(fileID, '%.15e, ', b);
+fprintf(fileID, '};');
+fclose(fileID); \ No newline at end of file
diff --git a/lab5/RTDSP/intio.c b/lab5/RTDSP/intio.c
index 2cc485a..2c47420 100644
--- a/lab5/RTDSP/intio.c
+++ b/lab5/RTDSP/intio.c
@@ -22,6 +22,7 @@
/**************************** Pre-processor statements ******************************/
#include <stdlib.h>
+#include <string.h>
// Included so program can make use of DSP/BIOS configuration tool.
#include "dsp_bios_cfg.h"
@@ -42,8 +43,7 @@
// PI defined here for use in your code
#define PI 3.141592653589793
-#include "Matlab/filter_coeff_ell_a.txt"
-#include "Matlab/filter_coeff_ell_b.txt"
+#include "Matlab/coeff2.txt"
int N = sizeof(a)/sizeof(a[0]);
short* x;
@@ -79,11 +79,12 @@ DSK6713_AIC23_CodecHandle H_Codec;
void init_hardware(void);
void init_HWI(void);
void ISR_AIC(void);
-short circ_fir(void);
/********************************** Main routine ************************************/
void main(){
x = (short*)calloc(N, sizeof(short));
- y = (double*)calloc(N, sizeof(double));
+ y = (double*)malloc(N * sizeof(double));
+ memset(y, 0.0, N * sizeof(double));
+
// initialize board and the audio port
init_hardware();
@@ -92,7 +93,6 @@ void main(){
/* loop indefinitely, waiting for interrupts */
while(1) {};
-
}
/********************************** init_hardware() **********************************/
@@ -132,22 +132,21 @@ void init_HWI()
/******************** INTERRUPT SERVICE ROUTINE ***********************/
void ISR_AIC()
{
- int i;
+ int i = N-1;
+ y[0] = 0.0;
+
//Shift the values
- for (i = N-1; i > 0; --i) {
+ for (; i > 0; --i) {
x[i] = x[i-1];
y[i] = y[i-1];
+
+ y[0] += b[i] * x[i] - a[i] * y[i];
}
-
+
x[0] = mono_read_16Bit();
- y[0] = 0.0;
-
- for (i = 0; i < N; ++i) {
- y[0] += b[i] * x[i];
- if (i != 0)
- y[0] -= a[i] * y[i];
- }
-
+
+ y[0] += b[0] * x[0];
+
mono_write_16Bit((short)y[0]);
-} \ No newline at end of file
+}