add matlab files
This commit is contained in:
parent
576d00eb05
commit
44a241d635
3
.gitmodule
Normal file
3
.gitmodule
Normal file
@ -0,0 +1,3 @@
|
||||
[module "wiki"]
|
||||
path = wiki
|
||||
url = https://bitbucket.org/HR_ELEKTRO/dis10.git/wiki
|
||||
BIN
matlab/0964590.wav
Normal file
BIN
matlab/0964590.wav
Normal file
Binary file not shown.
4
matlab/DIS10_lab1_1_1
Normal file
4
matlab/DIS10_lab1_1_1
Normal file
@ -0,0 +1,4 @@
|
||||
a = [1, -0.9, 0.6, -0.4]
|
||||
b = [0.5, -0.9]
|
||||
|
||||
impz(b, a, 10)
|
||||
14
matlab/DIS10_lab1_1_1.asv
Normal file
14
matlab/DIS10_lab1_1_1.asv
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
c_6=0;
|
||||
c_5=9;
|
||||
c_4=6;
|
||||
c_3=4;
|
||||
c_2=5;
|
||||
c_1=9;
|
||||
c_0=0;
|
||||
|
||||
a = [1, -0.1*c_5, 0.1*c_4, -0.c_3];
|
||||
b = [0.1*c_2, -0.1*c_1, 0.1*c_0];
|
||||
|
||||
%impz(b, a, 10) % opd B
|
||||
stepz(b, a, 25) % opd C
|
||||
15
matlab/DIS10_lab1_1_1.m
Normal file
15
matlab/DIS10_lab1_1_1.m
Normal file
@ -0,0 +1,15 @@
|
||||
%pkg load signal
|
||||
|
||||
c_6=4;%c_6=0;
|
||||
c_5=9;
|
||||
c_4=6;
|
||||
c_3=4;
|
||||
c_2=5;
|
||||
c_1=9;
|
||||
c_0=4;%c_0=0;
|
||||
|
||||
a = [1, -0.1*c_5, 0.1*c_4, -0.1*c_3];
|
||||
b = [0.1*c_2, -0.1*c_1, -0.1*c_0];
|
||||
|
||||
%impz(b, a, 10) % opd B
|
||||
stepz(b, a, 25) % opd C
|
||||
6
matlab/DIS10_lab1_1_2.m
Normal file
6
matlab/DIS10_lab1_1_2.m
Normal file
@ -0,0 +1,6 @@
|
||||
pkg load signals
|
||||
|
||||
a = [1, -0.4, 0.5];
|
||||
b = [0.9];
|
||||
|
||||
stepz(b, a, 100)
|
||||
31
matlab/DIS10_lab1_1_3.asv
Normal file
31
matlab/DIS10_lab1_1_3.asv
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
[x, Fs] = audioread('wannabe_in_la.wav');
|
||||
|
||||
len = length(x) / Fs % opd A
|
||||
|
||||
% opd B
|
||||
ft_x = fft(x);
|
||||
df = Fs / length(ft_x);
|
||||
f = (0 : length(ft_x) - 1) .* df;
|
||||
% plot(f, 20 * log10(abs(ft_x)))
|
||||
% xlabel('f (Hz)')
|
||||
% ylabel('|X| (dB)')
|
||||
% title('Frequentiespectrum |X(f)|')
|
||||
% grid
|
||||
|
||||
Fc = 300;
|
||||
p = Fs/(2*Fc) % opd C
|
||||
|
||||
k = 10; % opd D
|
||||
n = -k:k;
|
||||
b = sin(pi * n / p) ./ (pi * n) ;
|
||||
b(n == 0) = 1 / p;
|
||||
|
||||
freqz(b, 1, 0:(Fs/2), Fs);
|
||||
|
||||
tic;
|
||||
y = conv(b, x);
|
||||
toc;
|
||||
|
||||
|
||||
soundsc(y, Fs)
|
||||
43
matlab/DIS10_lab1_1_3.m
Normal file
43
matlab/DIS10_lab1_1_3.m
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
[x, Fs] = audioread('wannabe_in_la.wav');
|
||||
|
||||
len = length(x) / Fs % opd A
|
||||
|
||||
% opd B
|
||||
ft_x = fft(x);
|
||||
df = Fs / length(ft_x);
|
||||
f = (0 : length(ft_x) - 1) .* df;
|
||||
% plot(f, 20 * log10(abs(ft_x)))
|
||||
% xlabel('f (Hz)')
|
||||
% ylabel('|X| (dB)')
|
||||
% title('Frequentiespectrum |X(f)|')
|
||||
% grid
|
||||
|
||||
Fc = 300 + 100*5;
|
||||
p = Fs/(2*Fc) % opd C
|
||||
|
||||
% k = 10; % opd D
|
||||
% k = 100; % opd F
|
||||
k = 1000; % opd F
|
||||
% k = 10000; % opd F
|
||||
n = -k:k;
|
||||
b = sin(pi * n / p) ./ (pi * n) ;
|
||||
b(n == 0) = 1 / p;
|
||||
|
||||
freqz(b, 1, 0:(Fs/2), Fs);
|
||||
|
||||
tic; % opd G
|
||||
y = conv(b, x); % opd E
|
||||
toc; % opd G
|
||||
|
||||
% opd H
|
||||
ft_y = fft(y);
|
||||
df = Fs / length(ft_y);
|
||||
f = (0 : length(ft_y) - 1) .* df;
|
||||
% plot(f, 20 * log10(abs(ft_x)))
|
||||
% xlabel('f (Hz)')
|
||||
% ylabel('|X| (dB)')
|
||||
% title('Frequentiespectrum |X(f)|')
|
||||
% grid
|
||||
|
||||
soundsc(y, Fs)
|
||||
25
matlab/DIS10_lab1_1_6.asv
Normal file
25
matlab/DIS10_lab1_1_6.asv
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
[x, Fs] = audioread('wannabe_in_la.wav');
|
||||
ft_x = fft(x);
|
||||
|
||||
Fc = 300;
|
||||
p = Fs/(2*Fc);
|
||||
|
||||
H_f = zeros(length(ft_x), 1);
|
||||
do = length(H_f)/(2*pi);
|
||||
for k = 1:length(H_f)
|
||||
if k < do*(pi/p)
|
||||
H_f(k) = 1;
|
||||
end
|
||||
if k > do*(2*pi - pi/p)
|
||||
H_f(k) = 1;
|
||||
end
|
||||
end
|
||||
|
||||
tic;
|
||||
ft_x = fft(x);
|
||||
|
||||
ft_y = ft_x .* H_f;
|
||||
|
||||
y = ifft(ft_y, 'symmetric');
|
||||
toc;
|
||||
25
matlab/DIS10_lab1_1_6.m
Normal file
25
matlab/DIS10_lab1_1_6.m
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
[x, Fs] = audioread('wannabe_in_la.wav');
|
||||
ft_x = fft(x);
|
||||
|
||||
Fc = 300;
|
||||
p = Fs/(2*Fc);
|
||||
|
||||
H_f = zeros(length(ft_x), 1);
|
||||
do = length(H_f)/(2*pi);
|
||||
for k = 1:length(H_f)
|
||||
if k < do*(pi/p)
|
||||
H_f(k) = 1;
|
||||
end
|
||||
if k > do*(2*pi - pi/p)
|
||||
H_f(k) = 1;
|
||||
end
|
||||
end
|
||||
|
||||
tic;
|
||||
ft_x = fft(x);
|
||||
|
||||
ft_y = ft_x .* H_f;
|
||||
|
||||
y = ifft(ft_y, 'symmetric');
|
||||
toc;
|
||||
58
matlab/DIS10_lab2_0.asv
Normal file
58
matlab/DIS10_lab2_0.asv
Normal file
@ -0,0 +1,58 @@
|
||||
[ x, Fs ] = audioread("0964590.wav");
|
||||
|
||||
Fs
|
||||
|
||||
X = fftshift(fft(x));
|
||||
dF = Fs / length(X);
|
||||
dOmega = 2*pi / length(X);
|
||||
|
||||
f = -Fs/2 : dF : (Fs-dF)/2; % opd 2.1
|
||||
omega = -pi : dOmega : pi-dOmega; % opd 2.2
|
||||
|
||||
% plot(f, 20 * log10(abs(X))); % opd 2.1
|
||||
%plot(omega, 20 * log10(abs(X))); % opd 2.2
|
||||
%title('Frequentiespectrum |X(f)|');
|
||||
%xlabel('f (Hz)');
|
||||
%ylabel('|X| (dB)');
|
||||
%grid;
|
||||
|
||||
Oc = 0.461983;
|
||||
Og = 0.01;
|
||||
filterOrde = 128;
|
||||
|
||||
Oa = Oc - 0.5*Og;
|
||||
Ob = Oc + 0.5*Og;
|
||||
|
||||
H = ones(1, length(X));
|
||||
for i = round((pi-Oa)/dOmega) : round((pi-Ob)/dOmega)
|
||||
H(i) = 0;
|
||||
end
|
||||
for i = round((pi+Oa)/dOmega) : round((pi+Ob)/dOmega)
|
||||
H(i) = 0;
|
||||
end
|
||||
|
||||
%plot(omega, H);
|
||||
%title('filter ding |H(f)|');
|
||||
%xlabel('f (Hz)');
|
||||
%ylabel('|X| (dB)');
|
||||
%grid;
|
||||
|
||||
h = zeros(1, length(filterOrde));
|
||||
j = 1i;
|
||||
n = 0 : filterOrde/2;
|
||||
|
||||
%h = 1/(2*pi) * ( exp(i*Ob*n) - exp(i*Oa*n) + exp(i*-Ob*n) - exp(i*-Oa*n) )/exp(j*n);
|
||||
%h(n==0) = 1/(2*pi) * Og*2;
|
||||
h = ( exp(j*Oa*n) - 1 ...
|
||||
+ exp(j*(2*pi)*n) - exp(j*(2*pi-Oa)*n) ...
|
||||
+ exp(j*(2*pi-Ob)*n) - exp(j*Ob*n) ...
|
||||
)./(j*n*(2*pi));
|
||||
h(n==0) = 1/(2*pi) * 2*pi - Og*2;
|
||||
|
||||
%plot(0 : filterOrde/2, h);
|
||||
Fa = Oa * Fs/(2*pi)
|
||||
Fb = Ob * Fs/(2*pi)
|
||||
freqz(h, 1, 0 : Fs/2, Fs);
|
||||
|
||||
conv()
|
||||
|
||||
64
matlab/DIS10_lab2_0.m
Normal file
64
matlab/DIS10_lab2_0.m
Normal file
@ -0,0 +1,64 @@
|
||||
[ x, Fs ] = audioread("0964590.wav");
|
||||
|
||||
Fs
|
||||
|
||||
X = fftshift(fft(x));
|
||||
dF = Fs / length(X);
|
||||
dOmega = 2*pi / length(X);
|
||||
|
||||
f = -Fs/2 : dF : (Fs-dF)/2; % opd 2.1
|
||||
omega = -pi : dOmega : pi-dOmega; % opd 2.2
|
||||
|
||||
%plot(f, 20 * log10(abs(X))); % opd 2.1
|
||||
%plot(omega, 20 * log10(abs(X))); % opd 2.2
|
||||
%title('Frequentiespectrum |X(f)|');
|
||||
%xlabel('f (Hz)');
|
||||
%ylabel('|X| (dB)');
|
||||
%grid;
|
||||
|
||||
Oc = 0.461983;
|
||||
Og = 0.05;
|
||||
filterOrde = 1024*1024;
|
||||
|
||||
Oa = Oc - 0.5*Og;
|
||||
Ob = Oc + 0.5*Og;
|
||||
|
||||
H = ones(1, length(X));
|
||||
for i = round((pi-Oa)/dOmega) : round((pi-Ob)/dOmega)
|
||||
H(i) = 0;
|
||||
end
|
||||
for i = round((pi+Oa)/dOmega) : round((pi+Ob)/dOmega)
|
||||
H(i) = 0;
|
||||
end
|
||||
|
||||
%plot(omega, H);
|
||||
%title('filter ding |H(f)|');
|
||||
%xlabel('f (Hz)');
|
||||
%ylabel('|X| (dB)');
|
||||
%grid;
|
||||
|
||||
h = zeros(1, length(filterOrde));
|
||||
j = 1i;
|
||||
n = 0 : filterOrde/2;
|
||||
|
||||
%h = 1/(2*pi) * ( exp(i*Ob*n) - exp(i*Oa*n) + exp(i*-Ob*n) - exp(i*-Oa*n) )/exp(j*n);
|
||||
%h(n==0) = 1/(2*pi) * Og*2;
|
||||
h = ( exp(j*Oa*n) - 1 ...
|
||||
+ exp(j*(2*pi)*n) - exp(j*(2*pi-Oa)*n) ...
|
||||
+ exp(j*(2*pi-Ob)*n) - exp(j*Ob*n) ...
|
||||
)./(j*n*(2*pi));
|
||||
h(n==0) = 1/(2*pi) * 2*pi - Og*2;
|
||||
|
||||
%plot(0 : filterOrde/2, h);
|
||||
Fa = Oa * Fs/(2*pi)
|
||||
Fb = Ob * Fs/(2*pi)
|
||||
freqz(h, 1, 0 : Fs/2, Fs);
|
||||
|
||||
y = conv(x, h, 'same');
|
||||
|
||||
|
||||
Y = fftshift(fft(y));
|
||||
dF = Fs / length(Y);
|
||||
f = -Fs/2 : dF : (Fs-dF)/2;
|
||||
|
||||
%plot(f, 20 * log10(abs(Y)));
|
||||
1
matlab/DIS10_lab2_1_1.m
Normal file
1
matlab/DIS10_lab2_1_1.m
Normal file
@ -0,0 +1 @@
|
||||
dsp_assign(0, 9, 6, 4, 5, 9, 0)
|
||||
BIN
matlab/addfade.p
Normal file
BIN
matlab/addfade.p
Normal file
Binary file not shown.
BIN
matlab/calcparam.p
Normal file
BIN
matlab/calcparam.p
Normal file
Binary file not shown.
BIN
matlab/dsp_assign.p
Normal file
BIN
matlab/dsp_assign.p
Normal file
Binary file not shown.
35
matlab/fdacoefs.h
Normal file
35
matlab/fdacoefs.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool
|
||||
* Generated by MATLAB(R) 9.11 and DSP System Toolbox 9.13.
|
||||
* Generated on: 04-May-2022 20:48:48
|
||||
*/
|
||||
|
||||
/*
|
||||
* Discrete-Time FIR Filter (real)
|
||||
* -------------------------------
|
||||
* Filter Structure : Direct-Form FIR
|
||||
* Filter Length : 15
|
||||
* Stable : Yes
|
||||
* Linear Phase : Yes (Type 1)
|
||||
* Arithmetic : fixed
|
||||
* Numerator : s16,14 -> [-2 2)
|
||||
* Input : s16,15 -> [-1 1)
|
||||
* Filter Internals : Full Precision
|
||||
* Output : s33,29 -> [-8 8) (auto determined)
|
||||
* Product : s31,29 -> [-2 2) (auto determined)
|
||||
* Accumulator : s33,29 -> [-8 8) (auto determined)
|
||||
* Round Mode : No rounding
|
||||
* Overflow Mode : No overflow
|
||||
*/
|
||||
|
||||
/* General type conversion for MATLAB generated C-code */
|
||||
#include "tmwtypes.h"
|
||||
/*
|
||||
* Expected path to tmwtypes.h
|
||||
* /home/mreenen/.local/MATLAB/R2021b/extern/include/tmwtypes.h
|
||||
*/
|
||||
const int BL = 15;
|
||||
const int16_T B[15] = {
|
||||
-2107, -3477, -2950, 0, 4917, 10430, 14751, 16384, 14751,
|
||||
10430, 4917, 0, -2950, -3477, -2107
|
||||
};
|
||||
BIN
matlab/inputsound.mat
Normal file
BIN
matlab/inputsound.mat
Normal file
Binary file not shown.
BIN
matlab/wannabe_in_la.wav
Normal file
BIN
matlab/wannabe_in_la.wav
Normal file
Binary file not shown.
1
wiki
Submodule
1
wiki
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit f8fd582a70ea8883b615a90d48a687940d87797c
|
||||
Loading…
x
Reference in New Issue
Block a user