Skip to content

Commit 0458afb

Browse files
committed
add office noise
1 parent eee41c3 commit 0458afb

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

matlab/SRP-PHAT/SRP_PHAT.m

+25-11
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,62 @@
22
% Estimate the direction of arrival of a signal using the SRP-PHAT
33
% algorithm.
44
%%
5-
close all
5+
%close all
66
fs=16000; % sampling frequency (arbitrary)
77
D=2; % duration in seconds
88

99
L = ceil(fs*D)+1; % signal duration (samples)
1010
n = 0:L-1; % discrete-time axis (samples)
1111
t = n/fs; % discrete-time axis (sec)
1212
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+
1428
% x = filter(Num,1,x0);
1529
c = 340.0;
1630
%%
1731
% Create the 5-by-5 microphone URA.
18-
d = 0.05;
19-
N = 8;
32+
d = 0.042;
33+
N = 3;
2034
mic = phased.OmnidirectionalMicrophoneElement;
2135
array = phased.ULA(N,d,'Element',mic);
2236
% array = phased.URA([N,N],[d,d],'Element',mic);
2337

2438
%%
2539
% Simulate the incoming signal using the |WidebandCollector| System
2640
% object(TM).
27-
arrivalAng = [46;0];
41+
arrivalAng = [28;0];
2842
collector = phased.WidebandCollector('Sensor',array,'PropagationSpeed',c,...
2943
'SampleRate',fs,'ModulatedInput',false);
30-
signal = collector(x,arrivalAng);
44+
s = collector(speech,arrivalAng);
3145
% signal = signal(1:4800,:);
32-
46+
signal = s+noise;
3347
%%
3448
t = 0;
35-
P = 0;
49+
P = zeros(1,length(-90:step:90-step));
3650
step = 1;
3751
tic
38-
for i = -90:step:90
52+
for i = -90:step:90-step
3953
[ DS, x1] = phaseshift(signal,fs,256,256,128,d,i/180*pi);
4054
t = t+1;
4155
P(t) = DS'*DS;
4256
end
4357
toc
4458
[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
4761

4862

4963

noise/音轨-2.wav

124 KB
Binary file not shown.

noise/音轨-5.wav

124 KB
Binary file not shown.

noise/音轨.wav

124 KB
Binary file not shown.

0 commit comments

Comments
 (0)