-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.m
63 lines (52 loc) · 1.47 KB
/
code.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%1
[soundDada,sampleRate] = audioread('xtichy26.wav');
sampleCount=length(soundDada);
time=sampleCount/sampleRate;
%2
FourierTransformationOriginal = fft(soundDada);
vector = (0:sampleCount-1)*sampleRate/sampleCount;
moduleOriginal = abs(FourierTransformationOriginal);
plot(vector(1:sampleCount/2), moduleOriginal(1:sampleCount/2));
xlabel('f [Hz]');
ylabel('H [z]');
%3
[maxModuleOriginal, maxIndexOriginal] = max(sym(moduleOriginal));
maxOriginalHertz = vector(maxIndexOriginal);
%4
a = [1 0.2289 0.4662];
b = [0.2324 -0.4112 0.2324];
zplane(b,a);
%5
freq=(0:sampleCount-1) / sampleCount * sampleRate / 2;
H = freqz(b,a,sampleCount);
plot(freq, abs(H));
grid;
xlabel('f [Hz]');
ylabel('H [z]');
%6
filtered=filter(b,a,soundDada);
fourierTransformationFiltered=fft(filtered);
moduleFiltered=abs(fourierTransformationFiltered);
grid;
plot(vector(1:sampleCount/2), moduleFiltered(1:sampleCount/2));
xlabel('f [Hz]');
ylabel('H [z]');
%7
[maxModuleFiltered, maxIndexFiltered] = max(sym(moduleFiltered));
maxFilteredHertz = vector(maxIndexFiltered);
%8 TODO
%9
[Rv, lag] = xcorr(soundDada, 'biased');
plot(lag, Rv);
xlim([-50 50]);
%10
Rv10 = Rv(10 + sampleCount);
%11
x = linspace(min(soundDada), max(soundDada), 100);
[h,p,r] = hist2opt(soundDada(1:sampleCount-10), soundDada(11:sampleCount), x);
imagesc(-x,x,p);
axis xy;
colorbar;
%12 viz vystup hist2opt - 2d integral should be 1 and is 1
%13 viz vystup hist2opt -0.0230
disp(r);