├── README.md
├── SSL_4_SSC2_run.m
├── SSL_2_inverse_map_run.m
├── main.m
├── srp_phat_ssc.m
├── srp_phat_forward_map.m
├── srp_phat_tlssc.m
├── srp_phat_inverse_map.m
├── ld_vadlist.m
├── SSL_3_SSC.m
├── SSL_1_full_search.m
├── SSL_4_SSC2.m
└── SSL_2_inverse_map.m
/README.md:
--------------------------------------------------------------------------------
1 | # TL-SSC_SRP-PHAT
2 | SRP-PHAT using TL-SSC
3 |
4 | - Dongsuk Yook, Taewoo Lee, and Youngkyu Cho
5 | "[Fast Sound Source Localization Using Two-Level Search Space Clustering](http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=7039285&sortType=asc_p_Sequence&filter=AND(p_IS_Number:6352949))"
6 | IEEE Transactions on Cybernetics, In Press, Feb. 2015
7 |
8 | 실행 방법 (한국어): https://docs.google.com/document/d/167ikpTu33tch6G51xkK7tgLsFqUorkTl6eIz08WgIug/edit?usp=sharing
9 |
--------------------------------------------------------------------------------
/SSL_4_SSC2_run.m:
--------------------------------------------------------------------------------
1 | function []=SSL_4_SSC2_run(dataset_dir,tdoa_table_dir,tolerance)
2 | % Release date: May 2015
3 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
4 | %
5 | % Copyright (C) 2015 Taewoo Lee
6 | %
7 | % This program is free software: you can redistribute it and/or modify
8 | % it under the terms of the GNU General Public License as published by
9 | % the Free Software Foundation, either version 3 of the License, or
10 | % (at your option) any later version.
11 | %
12 | % This program is distributed in the hope that it will be useful,
13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | % GNU General Public License for more details.
16 | %
17 | % You should have received a copy of the GNU General Public License
18 | % along with this program. If not, see .
19 |
20 | for nn=[128 64 32 16 8 4 2 1]
21 | SSL_4_SSC2(dataset_dir,tdoa_table_dir,nn,tolerance);
22 | end
23 |
--------------------------------------------------------------------------------
/SSL_2_inverse_map_run.m:
--------------------------------------------------------------------------------
1 | function []=SSL_2_inverse_map_run(dataset_dir,tdoa_table_dir,tolerance)
2 | % Release date: May 2015
3 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
4 | %
5 | % Copyright (C) 2015 Taewoo Lee
6 | %
7 | % This program is free software: you can redistribute it and/or modify
8 | % it under the terms of the GNU General Public License as published by
9 | % the Free Software Foundation, either version 3 of the License, or
10 | % (at your option) any later version.
11 | %
12 | % This program is distributed in the hope that it will be useful,
13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | % GNU General Public License for more details.
16 | %
17 | % You should have received a copy of the GNU General Public License
18 | % along with this program. If not, see .
19 |
20 | for pp=[128 64 32 16 8 4 2 1 0]
21 | SSL_2_inverse_map(dataset_dir,tdoa_table_dir,pp,tolerance);
22 | end
23 |
--------------------------------------------------------------------------------
/main.m:
--------------------------------------------------------------------------------
1 | function []=main(dataset_dir,tdoa_table_dir)
2 | % Input: dataset_dir,
3 | % tdoa_table_dir (in which there are TDOA_table.mat,
4 | % cartCoords.mat, inverse_map.mat, micPair_min_max_table.mat,
5 | % TDOA_table_SSC.mat, SSC_centroids.mat, SSC.mat,
6 | % TDOA_table_SSC2.mat, SSC2_centroids.mat, SSC2.mat.)
7 | %
8 | % Release date: May 2015
9 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
10 | %
11 | % Copyright (C) 2015 Taewoo Lee
12 | %
13 | % This program is free software: you can redistribute it and/or modify
14 | % it under the terms of the GNU General Public License as published by
15 | % the Free Software Foundation, either version 3 of the License, or
16 | % (at your option) any later version.
17 | %
18 | % This program is distributed in the hope that it will be useful,
19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | % GNU General Public License for more details.
22 | %
23 | % You should have received a copy of the GNU General Public License
24 | % along with this program. If not, see .
25 |
26 | tolerance.theta= 10.001; % degree
27 | tolerance.phi= 5.001; % degree
28 |
29 | SSL_1_full_search(dataset_dir,tdoa_table_dir,tolerance)
30 | SSL_2_inverse_map_run(dataset_dir,tdoa_table_dir,tolerance)
31 | SSL_3_SSC(dataset_dir,tdoa_table_dir,tolerance)
32 | SSL_4_SSC2_run(dataset_dir,tdoa_table_dir,tolerance)
33 |
--------------------------------------------------------------------------------
/srp_phat_ssc.m:
--------------------------------------------------------------------------------
1 | function [max_srp_index]=srp_phat_ssc(f,TDOA_table_SSC,SSC_centroids)
2 | % Reference:
3 | % Youngkyu Cho, Dongsuk Yook, Seokmun Jang, and Hyunsoo Kim,
4 | % "Sound Source Localization for Robot Auditory Systems,"
5 | % IEEE Transactions on Consumer Electronics, vol. 55, no. 3, pp. 1663-1668,
6 | % Aug. 2009.
7 | %
8 | % Release date: May 2015
9 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
10 | %
11 | % Copyright (C) 2015 Taewoo Lee
12 | %
13 | % This program is free software: you can redistribute it and/or modify
14 | % it under the terms of the GNU General Public License as published by
15 | % the Free Software Foundation, either version 3 of the License, or
16 | % (at your option) any later version.
17 | %
18 | % This program is distributed in the hope that it will be useful,
19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | % GNU General Public License for more details.
22 | %
23 | % You should have received a copy of the GNU General Public License
24 | % along with this program. If not, see .
25 |
26 | M= size(f,1);
27 | N= M*(M-1)/2;
28 | T= size(f,2);
29 | Q= size(SSC_centroids,1);
30 |
31 | % GCC-PHAT
32 | X= zeros(M,T);
33 | for m=1:M
34 | X(m,:)= fft(f(m,:));
35 | X(m,:)= X(m,:)./abs(X(m,:));
36 | end
37 | Z= zeros(N,T);
38 | p= 0;
39 | for m1=1:M-1
40 | for m2=m1+1:M
41 | p= p+1;
42 | Z(p,:) = X(m1,:) .* conj(X(m2,:));
43 | end
44 | end
45 | R= zeros(N,T);
46 | for p=1:N
47 | R(p,:)= fftshift(real(ifft(Z(p,:))));
48 | end
49 |
50 | % SRP (Search Space Clustering)
51 | center= T/2;
52 | srp_global= zeros(Q,1);
53 | for q=1:Q
54 | srp_local= 0;
55 | for p=1:N
56 | tau_qp= TDOA_table_SSC(p,q) + center;
57 | srp_local= srp_local + R(p,tau_qp);
58 | end
59 | srp_global(q,1)= srp_local;
60 | end
61 |
62 | [~,max_srp_index]= max(srp_global);
--------------------------------------------------------------------------------
/srp_phat_forward_map.m:
--------------------------------------------------------------------------------
1 | function [max_srp_index]= srp_phat_forward_map(f, ... % M by T matrix
2 | TDOA_table)
3 | % Reference:
4 | % J. Dmochowski, J. Benesty, and S. Affes, "A generalized steered response
5 | % power method for computationally viable source localization,"
6 | % IEEE Transactions on Audio, Speech, and Language Processing, vol. 15,
7 | % pp. 2510-2526, 2007.
8 | %
9 | % Release date: May 2015
10 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
11 | %
12 | % Copyright (C) 2015 Taewoo Lee
13 | %
14 | % This program is free software: you can redistribute it and/or modify
15 | % it under the terms of the GNU General Public License as published by
16 | % the Free Software Foundation, either version 3 of the License, or
17 | % (at your option) any later version.
18 | %
19 | % This program is distributed in the hope that it will be useful,
20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | % GNU General Public License for more details.
23 | %
24 | % You should have received a copy of the GNU General Public License
25 | % along with this program. If not, see .
26 |
27 | M= size(f,1);
28 | N= M*(M-1)/2;
29 | T= size(f,2);
30 | Q= size(TDOA_table,2);
31 |
32 | % GCC-PHAT
33 | X= zeros(M,T);
34 | for m=1:M
35 | X(m,:)= fft(f(m,:));
36 | X(m,:)= X(m,:)./abs(X(m,:));
37 | end
38 | Z= zeros(N,T);
39 | p= 0;
40 | for m1=1:M-1
41 | for m2=m1+1:M
42 | p= p+1;
43 | Z(p,:)= X(m1,:).*conj(X(m2,:));
44 | end
45 | end
46 | R= zeros(N,T);
47 | for p=1:N
48 | R(p,:)= fftshift(real(ifft(Z(p,:))));
49 | end
50 |
51 | % SRP (full search or forward map)
52 | center= T/2;
53 | srp_global= zeros(Q,1);
54 | for q=1:Q
55 | srp_local= 0;
56 | for p=1:N
57 | tau_qp= TDOA_table(p,q) + center;
58 | srp_local= srp_local + R(p,tau_qp);
59 | end
60 | srp_global(q,1)= srp_local;
61 | end
62 |
63 | [~,max_srp_index]= max(srp_global);
--------------------------------------------------------------------------------
/srp_phat_tlssc.m:
--------------------------------------------------------------------------------
1 | function [max_srp_index]=srp_phat_tlssc(f, ...
2 | TDOA_table_SSC, ...
3 | TDOA_table_SSC2, ...
4 | SSC2, ...
5 | nn)
6 | % Reference:
7 | % Dongsuk Yook, Taewoo Lee, and Youngkyu Cho,
8 | % "Fast Sound Source Localization Using Two-Level Search Space Clustering,"
9 | % IEEE Transactions on Cybernetics, In Press, Feb. 2015.
10 | %
11 | % Release date: May 2015
12 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
13 | %
14 | % Copyright (C) 2015 Taewoo Lee
15 | %
16 | % This program is free software: you can redistribute it and/or modify
17 | % it under the terms of the GNU General Public License as published by
18 | % the Free Software Foundation, either version 3 of the License, or
19 | % (at your option) any later version.
20 | %
21 | % This program is distributed in the hope that it will be useful,
22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | % GNU General Public License for more details.
25 | %
26 | % You should have received a copy of the GNU General Public License
27 | % along with this program. If not, see .
28 |
29 | M= size(f,1);
30 | N= M*(M-1)/2;
31 | T= size(f,2);
32 | Q= size(SSC2,1);
33 | Q2= size(TDOA_table_SSC,1);
34 |
35 | % GCC-PHAT
36 | X= zeros(M,T);
37 | for m=1:M
38 | X(m,:)= fft(f(m,:));
39 | X(m,:)= X(m,:)./abs(X(m,:));
40 | end
41 | Z= zeros(N,T);
42 | p= 0;
43 | for m1=1:M-1
44 | for m2=m1+1:M
45 | p= p+1;
46 | Z(p,:)= X(m1,:).*conj(X(m2,:));
47 | end
48 | end
49 | R= zeros(N,T);
50 | for p=1:N
51 | R(p,:)= fftshift(real(ifft(Z(p,:))));
52 | end
53 |
54 | % SRP (TL-SSC first search)
55 | center= T/2;
56 | srp_global= zeros(Q,1);
57 | for q=1:Q
58 | srp_local= 0;
59 | for p=1:N
60 | tau_qp= TDOA_table_SSC2(p,q) + center;
61 | srp_local= srp_local + R(p,tau_qp);
62 | end
63 | srp_global(q,1)= srp_local;
64 | end
65 |
66 | % SRP (TL-SSC second search)
67 | [~,IX]= sort(srp_global,'descend');
68 | srp_global2= zeros(Q2,1);
69 | for j=1:nn
70 | cluster_indices= SSC2{IX(j,1),1}(:,1);
71 | n_search_index= size(cluster_indices,1);
72 | for q=1:n_search_index
73 | cluster_index= cluster_indices(q,1);
74 | srp_local= 0;
75 | for p=1:N
76 | tau_qp= TDOA_table_SSC(p,cluster_index) + center;
77 | srp_local= srp_local + R(p,tau_qp);
78 | end
79 | srp_global2(cluster_index,1)= srp_local;
80 | end
81 | end
82 |
83 | [~,max_srp_index]= max(srp_global2);
--------------------------------------------------------------------------------
/srp_phat_inverse_map.m:
--------------------------------------------------------------------------------
1 | function [max_srp_index]= srp_phat_inverse_map(...
2 | f, ... % M by T matrix
3 | inverse_map, ...
4 | micPair_min_max_table, ...
5 | pp, ...
6 | Q)
7 | % Reference:
8 | % J. Dmochowski, J. Benesty, and S. Affes, "A generalized steered response
9 | % power method for computationally viable source localization,"
10 | % IEEE Transactions on Audio, Speech, and Language Processing, vol. 15,
11 | % pp. 2510-2526, 2007.
12 | %
13 | % Release date: May 2015
14 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
15 | %
16 | % Copyright (C) 2015 Taewoo Lee
17 | %
18 | % This program is free software: you can redistribute it and/or modify
19 | % it under the terms of the GNU General Public License as published by
20 | % the Free Software Foundation, either version 3 of the License, or
21 | % (at your option) any later version.
22 | %
23 | % This program is distributed in the hope that it will be useful,
24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 | % GNU General Public License for more details.
27 | %
28 | % You should have received a copy of the GNU General Public License
29 | % along with this program. If not, see .
30 |
31 | M= size(f,1);
32 | N= M*(M-1)/2;
33 | T= size(f,2);
34 | max_tdoa= max(abs(micPair_min_max_table(:,1)));
35 | max_tdoa= max(max_tdoa,max(abs(micPair_min_max_table(:,2))));
36 |
37 | % GCC-PHAT
38 | X= zeros(M,T);
39 | for m=1:M
40 | X(m,:)= fft(f(m,:));
41 | X(m,:)= X(m,:)./abs(X(m,:));
42 | end
43 | Z= zeros(N,T);
44 | p= 0;
45 | for m1=1:M-1
46 | for m2=m1+1:M
47 | p= p+1;
48 | Z(p,:)= X(m1,:).*conj(X(m2,:));
49 | end
50 | end
51 | R= zeros(N,T);
52 | for p=1:N
53 | R(p,:)= fftshift(real(ifft(Z(p,:))));
54 | end
55 | peaks= zeros(N,1);
56 | for p=1:N
57 | center= T/2;
58 | [~,I]= max(R(p,center-max_tdoa:center+max_tdoa));
59 | peaks(p,1)= I-(max_tdoa+1);
60 | end
61 |
62 | % Search: SRP-PHAT inverse_map (p value of the paper is notated as pp
63 | % to void cofusing with pair index p).
64 | center= T/2;
65 | srp_global= zeros(Q,1);
66 | for p=1:N
67 | tdoa_start= max(peaks(p,1)-pp,micPair_min_max_table(p,1));
68 | tdoa_end= min(peaks(p,1)+pp,micPair_min_max_table(p,2));
69 | tdoa_range= tdoa_start:tdoa_end;
70 | n_tdoa= size(tdoa_range,2);
71 | for tdoa_idx=1:1:n_tdoa
72 | tdoa= tdoa_range(tdoa_idx);
73 | srp_local= R(p,tdoa+center);
74 | update_index= inverse_map{p,1}{tdoa_idx,1};
75 | srp_global(update_index)= srp_global(update_index) + ...
76 | srp_local;
77 | end
78 | end
79 |
80 | [~,max_srp_index]= max(srp_global);
81 |
--------------------------------------------------------------------------------
/ld_vadlist.m:
--------------------------------------------------------------------------------
1 | function [filelist]=ld_vadlist(dataset_dir)
2 | % Release date: May 2015
3 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
4 | %
5 | % Copyright (C) 2015 Taewoo Lee
6 | %
7 | % This program is free software: you can redistribute it and/or modify
8 | % it under the terms of the GNU General Public License as published by
9 | % the Free Software Foundation, either version 3 of the License, or
10 | % (at your option) any later version.
11 | %
12 | % This program is distributed in the hope that it will be useful,
13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | % GNU General Public License for more details.
16 | %
17 | % You should have received a copy of the GNU General Public License
18 | % along with this program. If not, see .
19 |
20 | %90
21 | filelist(1,:)={[dataset_dir '/090/1m/170cm/reverb020/out00.wav']};
22 | filelist(2,:)={[dataset_dir '/090/1m/170cm/reverb300/out00.wav']};
23 | filelist(3,:)={[dataset_dir '/090/1m/170cm/reverb500/out00.wav']};
24 | filelist(4,:)={[dataset_dir '/090/1m/170cm/reverb700/out00.wav']};
25 | filelist(5,:)={[dataset_dir '/090/1m/170cm/reverb900/out00.wav']};
26 | filelist(6,:)={[dataset_dir '/090/2m/170cm/reverb020/out00.wav']};
27 | filelist(7,:)={[dataset_dir '/090/2m/170cm/reverb300/out00.wav']};
28 | filelist(8,:)={[dataset_dir '/090/2m/170cm/reverb500/out00.wav']};
29 | filelist(9,:)={[dataset_dir '/090/2m/170cm/reverb700/out00.wav']};
30 | filelist(10,:)={[dataset_dir '/090/2m/170cm/reverb900/out00.wav']};
31 |
32 | %120
33 | filelist(11,:)={[dataset_dir '/120/1m/170cm/reverb020/out00.wav']};
34 | filelist(12,:)={[dataset_dir '/120/1m/170cm/reverb300/out00.wav']};
35 | filelist(13,:)={[dataset_dir '/120/1m/170cm/reverb500/out00.wav']};
36 | filelist(14,:)={[dataset_dir '/120/1m/170cm/reverb700/out00.wav']};
37 | filelist(15,:)={[dataset_dir '/120/1m/170cm/reverb900/out00.wav']};
38 | filelist(16,:)={[dataset_dir '/120/2m/170cm/reverb020/out00.wav']};
39 | filelist(17,:)={[dataset_dir '/120/2m/170cm/reverb300/out00.wav']};
40 | filelist(18,:)={[dataset_dir '/120/2m/170cm/reverb500/out00.wav']};
41 | filelist(19,:)={[dataset_dir '/120/2m/170cm/reverb700/out00.wav']};
42 | filelist(20,:)={[dataset_dir '/120/2m/170cm/reverb900/out00.wav']};
43 |
44 | %150
45 | filelist(21,:)={[dataset_dir '/150/1m/170cm/reverb020/out00.wav']};
46 | filelist(22,:)={[dataset_dir '/150/1m/170cm/reverb300/out00.wav']};
47 | filelist(23,:)={[dataset_dir '/150/1m/170cm/reverb500/out00.wav']};
48 | filelist(24,:)={[dataset_dir '/150/1m/170cm/reverb700/out00.wav']};
49 | filelist(25,:)={[dataset_dir '/150/1m/170cm/reverb900/out00.wav']};
50 | filelist(26,:)={[dataset_dir '/150/2m/170cm/reverb020/out00.wav']};
51 | filelist(27,:)={[dataset_dir '/150/2m/170cm/reverb300/out00.wav']};
52 | filelist(28,:)={[dataset_dir '/150/2m/170cm/reverb500/out00.wav']};
53 | filelist(29,:)={[dataset_dir '/150/2m/170cm/reverb700/out00.wav']};
54 | filelist(30,:)={[dataset_dir '/150/2m/170cm/reverb900/out00.wav']};
55 |
56 | %180
57 | filelist(31,:)={[dataset_dir '/180/1m/170cm/reverb020/out00.wav']};
58 | filelist(32,:)={[dataset_dir '/180/1m/170cm/reverb300/out00.wav']};
59 | filelist(33,:)={[dataset_dir '/180/1m/170cm/reverb500/out00.wav']};
60 | filelist(34,:)={[dataset_dir '/180/1m/170cm/reverb700/out00.wav']};
61 | filelist(35,:)={[dataset_dir '/180/1m/170cm/reverb900/out00.wav']};
62 | filelist(36,:)={[dataset_dir '/180/2m/170cm/reverb020/out00.wav']};
63 | filelist(37,:)={[dataset_dir '/180/2m/170cm/reverb300/out00.wav']};
64 | filelist(38,:)={[dataset_dir '/180/2m/170cm/reverb500/out00.wav']};
65 | filelist(39,:)={[dataset_dir '/180/2m/170cm/reverb700/out00.wav']};
66 | filelist(40,:)={[dataset_dir '/180/2m/170cm/reverb900/out00.wav']};
67 |
--------------------------------------------------------------------------------
/SSL_3_SSC.m:
--------------------------------------------------------------------------------
1 | function []=SSL_3_SSC(dataset_dir,tdoa_table_dir,tolerance)
2 | % Input: cartCoords.mat,
3 | % TDOA_table_SSC.mat,
4 | % SSC_centroids.mat
5 | % ~/VADed_data.mat.
6 | % Output: ./log/SSC.txt
7 | %
8 | % Reference:
9 | % Youngkyu Cho, Dongsuk Yook, Seokmun Jang, and Hyunsoo Kim,
10 | % "Sound Source Localization for Robot Auditory Systems,"
11 | % IEEE Transactions on Consumer Electronics, vol. 55, no. 3, pp. 1663-1668,
12 | % Aug. 2009.
13 | %
14 | % Release date: May 2015
15 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
16 | %
17 | % Copyright (C) 2015 Taewoo Lee
18 | %
19 | % This program is free software: you can redistribute it and/or modify
20 | % it under the terms of the GNU General Public License as published by
21 | % the Free Software Foundation, either version 3 of the License, or
22 | % (at your option) any later version.
23 | %
24 | % This program is distributed in the hope that it will be useful,
25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 | % GNU General Public License for more details.
28 | %
29 | % You should have received a copy of the GNU General Public License
30 | % along with this program. If not, see .
31 |
32 | DEBUG= 1;
33 | error_tolerance= tolerance.theta; % degree
34 | error_tolerance_phi= tolerance.phi; % degree
35 | load([tdoa_table_dir '/cartCoords.mat']);
36 | load([tdoa_table_dir '/TDOA_table_SSC.mat']);
37 | TDOA_table_SSC= TDOA_table_SSC';
38 | load([tdoa_table_dir '/SSC_centroids.mat']);
39 | filelist= ld_vadlist(dataset_dir);
40 | nfile= size(filelist,1);
41 |
42 | diary('off');
43 | delete('./log/SSC.txt');
44 | diary('./log/SSC.txt');
45 | disp('SRP-PHAT (SSC)');
46 | time= clock;
47 | fprintf('%s, %02d:%02d\n',date,time(4),time(5));
48 |
49 | for i=1:nfile
50 | filename= filelist{i,1};
51 | fnlen= size(filename,2);
52 | disp(filename);
53 | vadframe_filename= [filename(1:fnlen-9) 'VADed_data.mat'];
54 | load(vadframe_filename);
55 |
56 | ans_r= str2num(vadframe_filename(26)) * 1000;
57 | ans_height= 1700 - 400;
58 | ans_phi= (rad2deg(atan2(ans_height,ans_r)));
59 | ans_theta= str2num(vadframe_filename(22:24));
60 | if (DEBUG==1)
61 | fprintf('ans_theta=%d, ans_phi=%.2f, ans_r=%d\n', ...
62 | ans_theta,ans_phi,ans_r);
63 | end
64 |
65 | M= size(f2,1);
66 | nFrame= size(f2{1,1},1);
67 | T= size(f2{1,1},2);
68 |
69 | nCorrectFrame_theta= 0;
70 | nCorrectFrame_phi= 0;
71 | nCorrectFrame= 0;
72 | t1= clock;
73 | for f=1:nFrame
74 | input_frames= zeros(M,T);
75 | for m=1:M
76 | input_frames(m,:)= f2{m,1}(f,:);
77 | end
78 |
79 | % Search (SRP-PHAT SSC)
80 | I= srp_phat_ssc(input_frames,TDOA_table_SSC,SSC_centroids);
81 |
82 | [t,p,r]= cart2sph(SSC_centroids(I,1),SSC_centroids(I,2),SSC_centroids(I,3));
83 | theta= floor(abs(rad2deg(t)));
84 | phi= floor(abs(rad2deg(p)));
85 |
86 | error_theta= abs(ans_theta-theta);
87 | error_phi= abs(ans_phi-phi);
88 | if (error_theta<=error_tolerance)
89 | nCorrectFrame_theta= nCorrectFrame_theta+1;
90 | end
91 | if (error_phi<=error_tolerance_phi)
92 | nCorrectFrame_phi= nCorrectFrame_phi+1;
93 | end
94 | if (error_theta<=error_tolerance) && (error_phi<=error_tolerance_phi)
95 | nCorrectFrame= nCorrectFrame+1;
96 | end
97 |
98 | if (DEBUG==1)
99 | fprintf('%d:[%d/%d] ',i,f,nFrame);
100 | fprintf('theta=%03.2f, phi=%03.2f, r=%03.2f \n',theta,phi,r);
101 | end
102 | end
103 | exec_time= etime(clock,t1);
104 |
105 | fprintf('Execution time (total) = %f (sec)\n',exec_time);
106 | fprintf('Execution time per frame = %f (sec)\n',exec_time/nFrame);
107 | fprintf('Theta accuracy= %d/%d, (%.2f%%)\n', ...
108 | nCorrectFrame_theta,nFrame,nCorrectFrame_theta/nFrame*100);
109 | fprintf('Phi accuracy= %d/%d, (%.2f%%)\n', ...
110 | nCorrectFrame_phi,nFrame,nCorrectFrame_phi/nFrame*100);
111 | fprintf('Theta/phi accuracy= %d/%d, (%.2f%%)\n', ...
112 | nCorrectFrame,nFrame,nCorrectFrame/nFrame*100);
113 | fprintf('\n');
114 | end
115 | diary('off');
116 |
--------------------------------------------------------------------------------
/SSL_1_full_search.m:
--------------------------------------------------------------------------------
1 | function []=SSL_1_full_search(dataset_dir,tdoa_table_dir,tolerance)
2 | % Input: cartCoords.mat, TDOA_table.mat, ~/VADed_data.mat
3 | % Output: ./log/full_search.txt
4 | %
5 | % Reference:
6 | % J. Dmochowski, J. Benesty, and S. Affes, "A generalized steered response
7 | % power method for computationally viable source localization,"
8 | % IEEE Transactions on Audio, Speech, and Language Processing, vol. 15,
9 | % pp. 2510-2526, 2007.
10 | %
11 | % Release date: May 2015
12 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
13 | %
14 | % Copyright (C) 2015 Taewoo Lee
15 | %
16 | % This program is free software: you can redistribute it and/or modify
17 | % it under the terms of the GNU General Public License as published by
18 | % the Free Software Foundation, either version 3 of the License, or
19 | % (at your option) any later version.
20 | %
21 | % This program is distributed in the hope that it will be useful,
22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | % GNU General Public License for more details.
25 | %
26 | % You should have received a copy of the GNU General Public License
27 | % along with this program. If not, see .
28 |
29 | DEBUG= 1;
30 | error_tolerance= tolerance.theta; %degree
31 | error_tolerance_phi= tolerance.phi; %degree
32 | load([tdoa_table_dir '/cartCoords.mat']);
33 | load([tdoa_table_dir '/TDOA_table.mat']);
34 | TDOA_table= TDOA_table'; % For improving memory access pattern.
35 | filelist= ld_vadlist(dataset_dir);
36 | nfile= size(filelist,1);
37 |
38 | diary('off');
39 | delete('./log/full_search.txt');
40 | if exist('./log','dir')
41 | rmdir('./log','s');
42 | end
43 | mkdir('./log');
44 | diary('./log/full_search.txt');
45 | disp('Full-search (forward mapping SRP-PHAT)');
46 | time= clock;
47 | fprintf('%s, %d:%d\n',date,time(4),time(5));
48 |
49 | for i=1:nfile
50 | filename= filelist{i,1};
51 | fnlen= size(filename,2);
52 | disp(filename);
53 | vadframe_filename= [filename(1:fnlen-9) 'VADed_data.mat'];
54 | load(vadframe_filename);
55 |
56 | ans_r= str2num(vadframe_filename(26)) * 1000;
57 | ans_height= 1700 - 400;
58 | ans_phi= (rad2deg(atan2(ans_height,ans_r)));
59 | ans_theta= str2num(vadframe_filename(22:24));
60 | if (DEBUG==1)
61 | fprintf('ans_theta=%d, ans_phi=%.2f, ans_r=%d\n', ...
62 | ans_theta,ans_phi,ans_r);
63 | end
64 |
65 | M= size(f2,1);
66 | nFrame= size(f2{1,1},1);
67 | T= size(f2{1,1},2);
68 |
69 | nCorrectFrame_theta= 0;
70 | nCorrectFrame_phi= 0;
71 | nCorrectFrame= 0;
72 | t1= clock;
73 | for f=1:nFrame
74 | input_frames= zeros(M,T);
75 | for m=1:M
76 | input_frames(m,:)= f2{m,1}(f,:);
77 | end
78 |
79 | % Search (SRP-PHAT forward mapping)
80 | I= srp_phat_forward_map(input_frames,TDOA_table);
81 |
82 | [t,p,r]= cart2sph(cartCoords(I,1),cartCoords(I,2),cartCoords(I,3));
83 | theta= floor(abs(rad2deg(t)));
84 | phi= floor(abs(rad2deg(p)));
85 |
86 | % Error count
87 | error_theta= abs(ans_theta-theta);
88 | error_phi= abs(ans_phi-phi);
89 | if (error_theta<=error_tolerance)
90 | nCorrectFrame_theta= nCorrectFrame_theta+1;
91 | end
92 | if (error_phi<=error_tolerance_phi)
93 | nCorrectFrame_phi= nCorrectFrame_phi+1;
94 | end
95 | if ((error_theta<=error_tolerance) && (error_phi<=error_tolerance_phi))
96 | nCorrectFrame= nCorrectFrame+1;
97 | end
98 |
99 | if (DEBUG==1)
100 | fprintf('%d:[%d/%d] ',i,f,nFrame);
101 | fprintf('theta=%03.2f, phi=%03.2f, r=%03.2f \n',theta,phi,r);
102 | end
103 | end
104 | exec_time= etime(clock,t1);
105 |
106 | fprintf('Execution time (total) = %f (sec)\n',exec_time);
107 | fprintf('Execution time per frame = %f (sec)\n',exec_time/nFrame);
108 | fprintf('Theta accuracy= %d/%d, (%.2f%%)\n', ...
109 | nCorrectFrame_theta,nFrame,nCorrectFrame_theta/nFrame*100);
110 | fprintf('Phi accuracy= %d/%d, (%.2f%%)\n', ...
111 | nCorrectFrame_phi,nFrame,nCorrectFrame_phi/nFrame*100);
112 | fprintf('Theta/phi accuracy= %d/%d, (%.2f%%)\n', ...
113 | nCorrectFrame,nFrame,nCorrectFrame/nFrame*100);
114 | fprintf('\n');
115 | end
116 | diary('off');
117 |
--------------------------------------------------------------------------------
/SSL_4_SSC2.m:
--------------------------------------------------------------------------------
1 | function []=SSL_4_SSC2(dataset_dir,tdoa_table_dir,nn,tolerance)
2 | % Input: TDOA_table_SSC.mat
3 | % TDOA_table_SSC2.mat
4 | % SSC2.mat
5 | % SSC_centroids.mat
6 | % Output: ./log/SSC2_n_[**].txt
7 | %
8 | % Reference:
9 | % Dongsuk Yook, Taewoo Lee, and Youngkyu Cho,
10 | % "Fast Sound Source Localization Using Two-Level Search Space Clustering,"
11 | % IEEE Transactions on Cybernetics, In Press, Feb. 2015.
12 | %
13 | % Release date: May 2015
14 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
15 | %
16 | % Copyright (C) 2015 Taewoo Lee
17 | %
18 | % This program is free software: you can redistribute it and/or modify
19 | % it under the terms of the GNU General Public License as published by
20 | % the Free Software Foundation, either version 3 of the License, or
21 | % (at your option) any later version.
22 | %
23 | % This program is distributed in the hope that it will be useful,
24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 | % GNU General Public License for more details.
27 | %
28 | % You should have received a copy of the GNU General Public License
29 | % along with this program. If not, see .
30 |
31 | DEBUG= 1;
32 | error_tolerance= tolerance.theta; % degree
33 | error_tolerance_phi= tolerance.phi; % degree
34 | load([tdoa_table_dir '/SSC2.mat']);
35 | load([tdoa_table_dir '/TDOA_table_SSC.mat']);
36 | TDOA_table_SSC= TDOA_table_SSC';
37 | load([tdoa_table_dir '/TDOA_table_SSC2.mat']);
38 | TDOA_table_SSC2= TDOA_table_SSC2';
39 | load([tdoa_table_dir '/SSC_centroids.mat']);
40 | filelist= ld_vadlist(dataset_dir);
41 | nfile= size(filelist,1);
42 |
43 | diary('off');
44 | log_filename= sprintf('./log/SSC2_n_%02d.txt',nn);
45 | delete(log_filename);
46 | diary(log_filename);
47 | fprintf('SRP-PHAT (TL-SSC) (n=%d)\n',nn);
48 | time= clock;
49 | fprintf('%s, %02d:%02d\n',date,time(4),time(5));
50 |
51 | for i=1:nfile
52 | filename= filelist{i,1};
53 | fnlen= size(filename,2);
54 | disp(filename);
55 | vadframe_filename= [filename(1:fnlen-9) 'VADed_data.mat'];
56 | load(vadframe_filename);
57 |
58 | ans_r= str2num(vadframe_filename(26)) * 1000;
59 | ans_height= 1700 - 400;
60 | ans_phi= (rad2deg(atan2(ans_height,ans_r)));
61 | ans_theta= str2num(vadframe_filename(22:24));
62 | if (DEBUG==1)
63 | fprintf('ans_theta=%d, ans_phi=%.2f, ans_r=%d\n', ...
64 | ans_theta,ans_phi,ans_r);
65 | end
66 |
67 | M= size(f2,1);
68 | nFrame= size(f2{1,1},1);
69 | T= size(f2{1,1},2);
70 |
71 | nCorrectFrame_theta= 0;
72 | nCorrectFrame_phi= 0;
73 | nCorrectFrame= 0;
74 | t1= clock;
75 | for f=1:nFrame
76 | input_frames= zeros(M,T);
77 | for m=1:M
78 | input_frames(m,:)= f2{m,1}(f,:);
79 | end
80 |
81 | % Search (SRP-PHAT forward mapping)
82 | I= srp_phat_tlssc(input_frames,TDOA_table_SSC,TDOA_table_SSC2,SSC2,nn);
83 |
84 | [t,p,r]= cart2sph(SSC_centroids(I,1), ...
85 | SSC_centroids(I,2), ...
86 | SSC_centroids(I,3));
87 | theta= floor(abs(rad2deg(t)));
88 | phi= floor(abs(rad2deg(p)));
89 |
90 | error_theta= abs(ans_theta-theta);
91 | error_phi= abs(ans_phi-phi);
92 | if (error_theta<=error_tolerance)
93 | nCorrectFrame_theta= nCorrectFrame_theta+1;
94 | end
95 | if (error_phi<=error_tolerance_phi)
96 | nCorrectFrame_phi= nCorrectFrame_phi+1;
97 | end
98 | if (error_theta<=error_tolerance) && (error_phi<=error_tolerance_phi)
99 | nCorrectFrame= nCorrectFrame+1;
100 | end
101 |
102 | if (DEBUG==1)
103 | fprintf('%d:[%d/%d] ',i,f,nFrame);
104 | fprintf('theta=%03.2f, phi=%03.2f, r=%03.2f \n',theta,phi,r);
105 | end
106 | end
107 | exec_time= etime(clock,t1);
108 |
109 | fprintf('Execution time (total) = %f (sec)\n',exec_time);
110 | fprintf('Execution time per frame = %f (sec)\n',exec_time/nFrame);
111 | fprintf('Theta accuracy= %d/%d, (%.2f%%)\n', ...
112 | nCorrectFrame_theta,nFrame,nCorrectFrame_theta/nFrame*100);
113 | fprintf('Phi accuracy= %d/%d, (%.2f%%)\n', ...
114 | nCorrectFrame_phi,nFrame,nCorrectFrame_phi/nFrame*100);
115 | fprintf('Theta/phi accuracy= %d/%d, (%.2f%%)\n', ...
116 | nCorrectFrame,nFrame,nCorrectFrame/nFrame*100);
117 | fprintf('\n');
118 | end
119 | diary('off');
120 |
--------------------------------------------------------------------------------
/SSL_2_inverse_map.m:
--------------------------------------------------------------------------------
1 | function []=SSL_2_inverse_map(dataset_dir,tdoa_table_dir,pp,tolerance)
2 | % Input: cartCoords.mat,
3 | % inverse_map.mat,
4 | % micPair_min_max_table.mat,
5 | % ~/VADed_data.mat.
6 | % Output: ./log/inverse_map_p_[**].txt
7 | %
8 | % Reference:
9 | % J. Dmochowski, J. Benesty, and S. Affes, "A generalized steered response
10 | % power method for computationally viable source localization,"
11 | % IEEE Transactions on Audio, Speech, and Language Processing, vol. 15,
12 | % pp. 2510-2526, 2007.
13 | %
14 | % Release date: May 2015
15 | % Author: Taewoo Lee, (twlee@speech.korea.ac.kr)
16 | %
17 | % Copyright (C) 2015 Taewoo Lee
18 | %
19 | % This program is free software: you can redistribute it and/or modify
20 | % it under the terms of the GNU General Public License as published by
21 | % the Free Software Foundation, either version 3 of the License, or
22 | % (at your option) any later version.
23 | %
24 | % This program is distributed in the hope that it will be useful,
25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 | % GNU General Public License for more details.
28 | %
29 | % You should have received a copy of the GNU General Public License
30 | % along with this program. If not, see .
31 |
32 | DEBUG= 1;
33 | error_tolerance= tolerance.theta; % degree
34 | error_tolerance_phi= tolerance.phi; % degree
35 | load([tdoa_table_dir '/cartCoords.mat']);
36 | load([tdoa_table_dir '/inverse_map.mat']);
37 | load([tdoa_table_dir '/micPair_min_max_table.mat']);
38 |
39 | filelist= ld_vadlist(dataset_dir);
40 | nfile= size(filelist,1);
41 |
42 | diary('off');
43 | inverse_map_filename= sprintf('./log/inverse_map_p_%02d.txt',pp);
44 | delete(inverse_map_filename);
45 | diary(inverse_map_filename);
46 | fprintf('SRP-PHAT (Inverse mapping) (p=%d)\n',pp);
47 | time= clock;
48 | fprintf('%s, %d:%d\n',date,time(4),time(5));
49 |
50 | for i=1:nfile
51 | filename= filelist{i,1};
52 | fnlen= size(filename,2);
53 | disp(filename);
54 | vadframe_filename= [filename(1:fnlen-9) 'VADed_data.mat'];
55 | load(vadframe_filename);
56 |
57 | ans_r= str2num(vadframe_filename(26)) * 1000;
58 | ans_height= 1700 - 400;
59 | ans_phi= (rad2deg(atan2(ans_height,ans_r)));
60 | ans_theta= str2num(vadframe_filename(22:24));
61 | if (DEBUG==1)
62 | fprintf('ans_theta=%d, ans_phi=%.2f, ans_r=%d\n', ...
63 | ans_theta,ans_phi,ans_r);
64 | end
65 |
66 | M= size(f2,1);
67 | nFrame= size(f2{1,1},1);
68 | T= size(f2{1,1},2);
69 | Q= size(cartCoords,1);
70 |
71 | nCorrectFrame_theta= 0;
72 | nCorrectFrame_phi= 0;
73 | nCorrectFrame= 0;
74 | t1= clock;
75 | for f=1:nFrame
76 | input_frames= zeros(M,T);
77 | for m=1:M
78 | input_frames(m,:)= f2{m,1}(f,:);
79 | end
80 |
81 | % Search (SRP-PHAT forward mapping)
82 | I= srp_phat_inverse_map(input_frames, ...
83 | inverse_map, ...
84 | micPair_min_max_table, ...
85 | pp, ...
86 | Q);
87 |
88 | [t,p,r]= cart2sph(cartCoords(I,1),cartCoords(I,2),cartCoords(I,3));
89 | theta= floor(abs(rad2deg(t)));
90 | phi= floor(abs(rad2deg(p)));
91 |
92 | % Error count
93 | error_theta= abs(ans_theta-theta);
94 | error_phi= abs(ans_phi-phi);
95 | if (error_theta<=error_tolerance)
96 | nCorrectFrame_theta= nCorrectFrame_theta+1;
97 | end
98 | if (error_phi<=error_tolerance_phi)
99 | nCorrectFrame_phi= nCorrectFrame_phi+1;
100 | end
101 | if (error_theta<=error_tolerance) && (error_phi<=error_tolerance_phi)
102 | nCorrectFrame= nCorrectFrame+1;
103 | end
104 |
105 | if (DEBUG==1)
106 | fprintf('%d:[%d/%d] ',i,f,nFrame);
107 | fprintf('theta=%03.2f, phi=%03.2f, r=%03.2f \n',theta,phi,r);
108 | end
109 | end
110 | exec_time= etime(clock,t1);
111 |
112 | fprintf('Execution time (total) = %f (sec)\n',exec_time);
113 | fprintf('Execution time per frame = %f (sec)\n',exec_time/nFrame);
114 | fprintf('Theta accuracy= %d/%d, (%.2f%%)\n', ...
115 | nCorrectFrame_theta,nFrame,nCorrectFrame_theta/nFrame*100);
116 | fprintf('Phi accuracy= %d/%d, (%.2f%%)\n', ...
117 | nCorrectFrame_phi,nFrame,nCorrectFrame_phi/nFrame*100);
118 | fprintf('Theta/phi accuracy= %d/%d, (%.2f%%)\n', ...
119 | nCorrectFrame,nFrame,nCorrectFrame/nFrame*100);
120 | fprintf('\n');
121 | end
122 | diary('off');
123 |
--------------------------------------------------------------------------------