-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathreadData.m
69 lines (69 loc) · 2.53 KB
/
readData.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
function [s,Ori_s,Unmix_s,SetupStruc] = readData(Angle,SetupStruc,channel)
Num = length(Angle);
SetupStruc.Angle = Angle;
T60 = SetupStruc.T60;
Sign_compared = SetupStruc.Sign_compared;
Channel_Num = SetupStruc.Channel_Num;
Len = zeros(Num,1);
if(~exist('channel','var'))
channel = 1;
end
if(SetupStruc.Sign_Mid==1)
channel_line = 0:Channel_Num-1;
else
channel_line = 1:Channel_Num;
end
for n = 1:Num
if(SetupStruc.Height==1)
dataPath = 'simu_data/DifferentHeight/T60_';
else
dataPath = 'simu_data/SameHeight/T60_';
end
for i = channel_line%0:Channel_Num-1
wavName =strcat(dataPath,num2str(T60),'/',num2str(Angle(n)),'/Mic',num2str(i),'.wav');
if(SetupStruc.Sign_Mid==1)
eval(strcat('[s_temp', num2str(n), '(:,', num2str(i), '+1),fs] = audioread(''', wavName, ''');'));
else
eval(strcat('[s_temp', num2str(n), '(:,', num2str(i), '),fs] = audioread(''', wavName, ''');'));
end
end
eval(strcat('Len(n) = size(s_temp', num2str(n),',1);'));
end
SetupStruc.fs = fs;
len = min(Len);
s = s_temp1(1:len,:);
Unmix_s(:,:,1) = s;
if(Num>1)
Ori_s = zeros(len,Num);
Ori_s(:,1) = s_temp1(1:len,channel);
else
Ori_s = zeros(len,2);
Ori_s_temp = audioread(strcat(dataPath,'0/',num2str(Angle(1)),'/Mic0.wav'));
Ori_s(:,1) = Ori_s_temp(1:len);
Ori_s(:,2) = s_temp1(1:len,channel);
end
for n = 2:Num
eval(strcat('s_temp = s_temp', num2str(n), ';'));
s = s+s_temp(1:len,:);
Unmix_s(:,:,n) = s_temp(1:len,:);
Ori_s(:,n) = s_temp(1:len,channel);
end
if(Sign_compared<0 && Num>1)
for i = 1:Num
%%%% In the last version, if Sign_compared>-1, choose the signal in
%%%% the T60=0s, else in the select T60
% Ori_s_temp = audioread(strcat(dataPath,'0/',num2str(Angle(i)),'/Mic',num2str(Sign_compared),'.wav'));
%%%% In this version, if Sign_compared<0, chosse the original
%%%% signal, else choose the select T60
Ori_s_temp = audioread(strcat('simu_data/oral/',num2str(Angle(i)),'.wav'));
Ori_s(:,i) = Ori_s_temp(1:len);
end
end
if(SetupStruc.AddNoiseFlag==1)
av_pow = mean( sum(s.^2,1)/len ); % Average mic power across all received signals.
sigma_noise = sqrt( av_pow/(10^(SetupStruc.NoiseSNR/10)) ); % st. dev. of white noise component to achieve desired SNR.
s = s + sigma_noise*randn(size(s)); % Add some random noise
end
% autoPlot(Ori_s,fs,-1); %%%the 3rd parameter is used to control whether adjusting the range of y axis when equal -1
% autoPlot(s(:,1),fs);
return;