-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse
executable file
·44 lines (36 loc) · 913 Bytes
/
analyse
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
#!/usr/bin/octave -f
pkg load signal;
input = argv(){1};
[~, name] = fileparts(input);
[y, fs] = audioread(input);
[h, hf] = freqz(y, 1, 65536, fs);
[g, gf] = grpdelay(y, 1, 65536, fs);
gain_db = mag2db(abs(h));
phase = rad2deg(unwrap(angle(h)));
grpdelay_ms = g / fs * 1000;
fig = figure("Name", input, "position", [0, 0, 400, 800]);
subplot(3, 1, 1);
plot(hf, gain_db);
set(gca, "XScale", "log");
grid on;
title("Frequency Response");
xlabel("Frequency (Hz)");
ylabel("Magnitude (dB)");
axis([1, fs/2, -20, 20]);
subplot(3, 1, 2);
plot(hf, phase);
set(gca, "XScale", "log");
grid on;
title("Phase Response");
xlabel("Frequency (Hz)");
ylabel("Phase (degrees)");
axis([1, fs/2, -180, 180]);
subplot(3, 1, 3);
plot(gf, grpdelay_ms);
set(gca, "XScale", "log");
grid on;
title("Group Delay");
xlabel("Frequency (Hz)");
ylabel("Group Delay (ms)");
axis([1, fs/2, 0, 10]);
print(fig, [name ".png"], "-dpng");