-
Notifications
You must be signed in to change notification settings - Fork 5
/
wideband_doa_test2.m
74 lines (71 loc) · 2.24 KB
/
wideband_doa_test2.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
64
65
66
67
68
69
70
71
72
73
74
addpath './DOAToolbox'
addpath './wav'
%% Initializations
%Variables:
%Fixed:
% l: distance between sensors in m
% m: number of sensors
% fs: sampling frequency
%Tunables:
% wlen: affects frequency precision, is the most important parameter
% bins: number of samples for the narrowband algo to work with
% wlen and bins set the total number of necessary samples, N
% olf: overlapping factor, integer between 0 and wlen-1
% L: precision/ resolution, how many slices to divide the angle domain
l = 0.04; %distance between sensors in m
m = 8; %num of sensors
fs = 8820; %sampling frequency
wlen = 256; %fft order, or window size
bins = 10; %num of windows
olf = wlen/2; %overlapping factor for stft( fft_separate)
N = wlen * bins * 5; %num of samples
L = 180; %num of divisions for [-pi/2, pi/2]
%% Signal composition
[highb,Fs] = wavread('mono_highb.wav');
d3 = wavread('mono_d3.wav');
fc = 1000:50:1500;
Ya = simsound_planar(13*pi/180, m, l, highb(:,1), Fs);
Yb = simsound_planar(-45*pi/180, m, l, d3(:,1), Fs);
Yc = simband_planar(-34 * pi/180, m, l, fc, Fs, N);
dsfactor = 5; % 'downsampling' factor
fs = Fs / dsfactor;
minlines = min(size(Ya,1), size(Yc,1));
Y = Ya(1:minlines,:) + Yc(1:minlines, :) * 0.01;
%Y = Ya;
Y = Y(1:dsfactor:end,:);
%Y = addnoise(Y, sig);
n = 2;
%% Wideband DOA
[N, phicapon, phimusic, thetaesprit, f] = wideband_doa(real(Y), l, fs, n, wlen, bins, olf, L);
%% Playback
player = audioplayer(real(Y(1:N,:)), fs);
playblocking(player);
%% Plotting
% figure(3)
% plot(t, real(Y));
% xlabel('Time');
% ylabel('Value');
% title('Data set');
% legend('Sensor 1','Sensor 2','Sensor 3','Sensor 4','Sensor 5','Sensor 6','Sensor 7','Sensor 8');
% grid on
%% Plot the spatial spectrum
figure(1)
x = ((0:(L-1)) .* pi/L - pi/2); % x in radians
x = x * 180/pi; %x in degrees
imagesc(x,f, phicapon.');
xlabel('Degrees');
ylabel('Frequency');
title('Capon estimation');
grid on
figure(2)
x = ((0:(L-1)) .* pi/L - pi/2); % x in radians
x = x * 180/pi; %x in degrees
imagesc(x,f, phimusic.');
xlabel('Degrees');
ylabel('Frequency');
title('MUSIC estimation');
grid on
%% Clean-up
rmpath './DOAToolbox'
rmpath './wav'
clear Fs L N Y Ya Yb Yc bins d3 dsfactor f fc fs highb l m minlines n olf phicapon phimusic player thetaesprit wlen x