aboutsummaryrefslogtreecommitdiffstats
path: root/lab5/RTDSP/intio.c
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2018-02-27 12:20:40 +0000
committerymherklotz <ymherklotz@gmail.com>2018-02-27 12:20:40 +0000
commit8c4c776fedeb003055d3badde73ae014c1d51a8d (patch)
tree0527dcc2fa4645726321093d1dd7349fb9c8ab89 /lab5/RTDSP/intio.c
parent1a354b47a09800805ecdf6a0ec24fc1f67405bd8 (diff)
downloadNoiseSilencer-8c4c776fedeb003055d3badde73ae014c1d51a8d.tar.gz
NoiseSilencer-8c4c776fedeb003055d3badde73ae014c1d51a8d.zip
Added efficient code
Diffstat (limited to 'lab5/RTDSP/intio.c')
-rw-r--r--lab5/RTDSP/intio.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/lab5/RTDSP/intio.c b/lab5/RTDSP/intio.c
index 567324c..e7ae084 100644
--- a/lab5/RTDSP/intio.c
+++ b/lab5/RTDSP/intio.c
@@ -43,7 +43,7 @@
// PI defined here for use in your code
#define PI 3.141592653589793
-#include "Matlab/coeff2.txt"
+#include "Matlab/coeff.txt"
int N = sizeof(a)/sizeof(a[0]);
short* x;
@@ -133,23 +133,21 @@ void init_HWI()
void ISR_AIC()
{
int i = N-1;
+ double Y = 0.0;
//Shift the values
for (; i > 0; --i) {
x[i] = x[i-1];
y[i] = y[i-1];
+
+ Y += x[i] * b[i] - y[i] * a[i];
}
x[0] = mono_read_16Bit();
- y[0] = 0.0;
+ Y += x[0] * b[0];
- for (i = 0; i < N; ++i) {
- y[0] += x[i] * b[i];
- if(i != 0) {
- y[0] -= y[i] * a[i];
- }
- }
+ y[0] = Y;
- mono_write_16Bit((short)y[0]);
+ mono_write_16Bit((short)Y);
}