diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-01-29 12:15:34 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-01-29 12:15:34 +0000 |
commit | 8ae00d0644561e4211e0531b29ffff876c092f25 (patch) | |
tree | c71eb83f5c5402e96b2e06add8b2616c6e6e70fe | |
parent | ef69ae72e9163f0e4caedbf682f84510be8771f1 (diff) | |
download | NoiseSilencer-8ae00d0644561e4211e0531b29ffff876c092f25.tar.gz NoiseSilencer-8ae00d0644561e4211e0531b29ffff876c092f25.zip |
[lab2] Small fix and adding python script
-rw-r--r-- | lab2/RTDSP/sine.c | 2 | ||||
-rw-r--r-- | lab2/filter.py | 24 | ||||
-rw-r--r-- | lab2/requirements.txt | 8 |
3 files changed, 33 insertions, 1 deletions
diff --git a/lab2/RTDSP/sine.c b/lab2/RTDSP/sine.c index 60fb454..329d082 100644 --- a/lab2/RTDSP/sine.c +++ b/lab2/RTDSP/sine.c @@ -168,7 +168,7 @@ float sinegen() wave = table[(int)((sine_freq / (float)sampling_freq) * (float)SINE_TABLE_SIZE * (float)sine_index) % SINE_TABLE_SIZE]; - sine_index = (sine_index + 1) % sampling_freq; + sine_index++; return wave; } diff --git a/lab2/filter.py b/lab2/filter.py new file mode 100644 index 0000000..c35f75e --- /dev/null +++ b/lab2/filter.py @@ -0,0 +1,24 @@ +from math import sqrt +import matplotlib.pyplot as plt + + +a0 = sqrt(2) +b0 = 1/sqrt(2) + +y = [0, 0, 0] +x = [1] + +result = [0] + +for i in range(0, 8): + y[0] = a0 * y[1] - y[2] + b0 * x[0] + result.append(y[0]) + y[2] = y[1] + y[1] = y[0] + x[0] = 0 + +plt.plot(result) +plt.title("Filter Output") +plt.ylabel("y: sin(x)") +plt.xlabel("x: sample") +plt.show() diff --git a/lab2/requirements.txt b/lab2/requirements.txt new file mode 100644 index 0000000..6d456f7 --- /dev/null +++ b/lab2/requirements.txt @@ -0,0 +1,8 @@ +cycler==0.10.0 +matplotlib==2.1.2 +numpy==1.14.0 +pyparsing==2.2.0 +python-dateutil==2.6.1 +pytz==2017.3 +six==1.11.0 +tabulate==0.8.2 |