|
2 | 2 | % Estimate the direction of arrival of a signal using the SRP-PHAT
|
3 | 3 | % algorithm.
|
4 | 4 | %%
|
5 |
| -close all |
| 5 | +%close all |
6 | 6 | fs=16000; % sampling frequency (arbitrary)
|
7 | 7 | D=2; % duration in seconds
|
8 | 8 |
|
9 | 9 | L = ceil(fs*D)+1; % signal duration (samples)
|
10 | 10 | n = 0:L-1; % discrete-time axis (samples)
|
11 | 11 | t = n/fs; % discrete-time axis (sec)
|
12 | 12 | x = chirp(t,0,D,fs/2)'; % sine sweep from 0 Hz to fs/2 Hz
|
13 |
| -[x,fs]=audioread('../speech.wav'); |
| 13 | + |
| 14 | +%% load recorded office noise audio |
| 15 | +noisepath = '../../noise/'; |
| 16 | +[noise2,fs] = audioread([noisepath,'Òô¹ì-2.wav']); |
| 17 | +noise0 = audioread([noisepath,'Òô¹ì.wav']); |
| 18 | +noise5 = audioread([noisepath,'Òô¹ì-5.wav']); |
| 19 | +noise = [noise2,noise0,noise5]; |
| 20 | + |
| 21 | +%use a clean speech audio as desired signal |
| 22 | +pathname = '../'; |
| 23 | +[speech ,fs] = audioread([pathname,'speech.wav']); |
| 24 | +%scale source signal to obtain 0 dB input SNR |
| 25 | +speech = speech(1:length(noise0))/2; |
| 26 | + |
| 27 | + |
14 | 28 | % x = filter(Num,1,x0);
|
15 | 29 | c = 340.0;
|
16 | 30 | %%
|
17 | 31 | % Create the 5-by-5 microphone URA.
|
18 |
| -d = 0.05; |
19 |
| -N = 8; |
| 32 | +d = 0.042; |
| 33 | +N = 3; |
20 | 34 | mic = phased.OmnidirectionalMicrophoneElement;
|
21 | 35 | array = phased.ULA(N,d,'Element',mic);
|
22 | 36 | % array = phased.URA([N,N],[d,d],'Element',mic);
|
23 | 37 |
|
24 | 38 | %%
|
25 | 39 | % Simulate the incoming signal using the |WidebandCollector| System
|
26 | 40 | % object(TM).
|
27 |
| -arrivalAng = [46;0]; |
| 41 | +arrivalAng = [28;0]; |
28 | 42 | collector = phased.WidebandCollector('Sensor',array,'PropagationSpeed',c,...
|
29 | 43 | 'SampleRate',fs,'ModulatedInput',false);
|
30 |
| -signal = collector(x,arrivalAng); |
| 44 | +s = collector(speech,arrivalAng); |
31 | 45 | % signal = signal(1:4800,:);
|
32 |
| - |
| 46 | +signal = s+noise; |
33 | 47 | %%
|
34 | 48 | t = 0;
|
35 |
| -P = 0; |
| 49 | +P = zeros(1,length(-90:step:90-step)); |
36 | 50 | step = 1;
|
37 | 51 | tic
|
38 |
| -for i = -90:step:90 |
| 52 | +for i = -90:step:90-step |
39 | 53 | [ DS, x1] = phaseshift(signal,fs,256,256,128,d,i/180*pi);
|
40 | 54 | t = t+1;
|
41 | 55 | P(t) = DS'*DS;
|
42 | 56 | end
|
43 | 57 | toc
|
44 | 58 | [m,index] = max(P);
|
45 |
| -figure,plot(-90:step:90,P/max(P)) |
46 |
| -(index-90)*step |
| 59 | +hold on,plot(-90:step:90-step,P/max(P)) |
| 60 | +(index-90+step)*step |
47 | 61 |
|
48 | 62 |
|
49 | 63 |
|
|
0 commit comments