|
136 | 136 |
|
137 | 137 | % Plots
|
138 | 138 | % impulse responses
|
139 |
| -figure |
140 |
| - plot(0:N-1,squeeze(irs1(1,1,:)),'k'), hold on |
141 |
| - plot(0:N-1,squeeze(irs1(2,1,:)),'b') |
142 |
| - plot(0:N-1,squeeze(h_int1_simple(1,1,:)),'r') |
143 |
| - plot(0:N-1,squeeze(h_int1_fd(1,1,:)),'m') |
144 |
| - plot(0:N-1,squeeze(h_int1_td(1,1,:)),'c') |
| 139 | +ir_list = { |
| 140 | + irs1(1,1,:) , irs2(1,1,:) , irs3(1,1,:) |
| 141 | + irs1(2,1,:) , irs2(2,1,:) , irs3(2,1,:) |
| 142 | + h_int1_simple(1,1,:), h_int2_simple(1,1,:) , h_int3_simple(1,1,:) |
| 143 | + h_int1_fd(1,1,:) , h_int2_fd(1,1,:) , h_int3_fd(1,1,:) |
| 144 | + h_int1_td(1,1,:) , h_int2_td(1,1,:) , h_int3_td(1,1,:) |
| 145 | + }; % list of IRs |
| 146 | + |
| 147 | +col = {'k' 'b' 'r' 'm' 'c'}; |
| 148 | + |
| 149 | +titlelabels = { |
| 150 | + 'Interpolation between Dirac impulses with one sample in between' |
| 151 | + 'Interpolation of neighbouring Dirac impulses at impulse response start' |
| 152 | + 'Interpolation of neighbouring Dirac impulses in middle of impulse response' |
| 153 | + }; |
| 154 | + |
| 155 | +t = 0:N-1; % time-axis in samples |
| 156 | + |
| 157 | +for cdx=1:size(ir_list,2) |
| 158 | + figure |
| 159 | + for rdx=1:size(ir_list,1) |
| 160 | + plot(t,squeeze(ir_list{rdx, cdx}), col{rdx}) |
| 161 | + hold on |
| 162 | + end |
| 163 | + hold off |
145 | 164 | grid
|
146 |
| - xlabel('samples'), ylabel('amplitude') |
| 165 | + xlabel('samples') |
| 166 | + ylabel('amplitude') |
147 | 167 | legend('h_1','h_2','simple interp','freqdomain interp','timedomain interp')
|
148 |
| - title('Interpolation between Dirac impulses with one sample in between') |
149 |
| - |
150 |
| -figure |
151 |
| - plot(0:N-1,squeeze(irs2(1,1,:)),'k'), hold on |
152 |
| - plot(0:N-1,squeeze(irs2(2,1,:)),'b') |
153 |
| - plot(0:N-1,squeeze(h_int2_simple(1,1,:)),'r') |
154 |
| - plot(0:N-1,squeeze(h_int2_fd(1,1,:)),'m') |
155 |
| - plot(0:N-1,squeeze(h_int2_td(1,1,:)),'c') |
156 |
| - grid |
157 |
| - xlabel('samples'), ylabel('amplitude') |
158 |
| - legend('h_1','h_2','simple interp','freqdomain interp','timedomain interp') |
159 |
| - title('Interpolation of neighbouring Dirac impulses at impulse response start') |
160 |
| - |
161 |
| -figure |
162 |
| - plot(0:N-1,squeeze(irs3(1,1,:)),'k'), hold on |
163 |
| - plot(0:N-1,squeeze(irs3(2,1,:)),'b') |
164 |
| - plot(0:N-1,squeeze(h_int3_simple(1,1,:)),'r') |
165 |
| - plot(0:N-1,squeeze(h_int3_fd(1,1,:)),'m') |
166 |
| - plot(0:N-1,squeeze(h_int3_td(1,1,:)),'c') |
167 |
| - grid |
168 |
| - xlabel('samples'), ylabel('amplitude') |
169 |
| - legend('h_1','h_2','simple interp','freqdomain interp','timedomain interp') |
170 |
| - title('Interpolation of neighbouring Dirac impulses in middle of impulse response') |
171 |
| - |
| 168 | + title(titlelabels{cdx}) |
| 169 | +end |
172 | 170 |
|
173 | 171 | %% ===== Interpolate HRIRs ===============================================
|
174 | 172 | % 1. Interpolate between close HRIRs
|
175 |
| -idx0 = 181; %index for 0° azimuth |
176 |
| -idx1 = 182; %index for 1° azimuth |
177 |
| -idx2 = 183; %index for 2° azimuth |
| 173 | +idx0 = 181; %index for 0° azimuth |
| 174 | +idx1 = 182; %index for 1° azimuth |
| 175 | +idx2 = 183; %index for 2° azimuth |
178 | 176 | x0_close = [hrtf.SourcePosition(idx0,:).' hrtf.SourcePosition(idx2,:).']/180*pi;
|
179 | 177 | % weights (for target point: xs_close = hrtf.SourcePosition(idx1,:).'/180*pi )
|
180 | 178 | weights_close = [.5; .5];
|
|
189 | 187 | hrir_close_td = interpolate_ir(hrir_close,weights_close,conf);
|
190 | 188 |
|
191 | 189 | % 2. Interpolate between distant HRIRs
|
192 |
| -idx0 = 181; %index for 0° azimuth |
193 |
| -idx30 = 211; %index for 30° azimuth |
194 |
| -idx60 = 241; %index for 60° azimuth |
| 190 | +idx0 = 181; %index for 0° azimuth |
| 191 | +idx30 = 211; %index for 30° azimuth |
| 192 | +idx60 = 241; %index for 60° azimuth |
195 | 193 | x0_dist = [hrtf.SourcePosition(idx0,:).' hrtf.SourcePosition(idx60,:).']/180*pi;
|
196 | 194 | % weights (for target point: xs_dist = hrtf.SourcePosition(idx30,:).'/180*pi )
|
197 | 195 | weights_dist = [.5; .5];
|
|
206 | 204 | hrir_dist_td = interpolate_ir(hrir_dist,weights_dist,conf);
|
207 | 205 |
|
208 | 206 | % Plots
|
209 |
| -% impulse responses |
210 |
| -figure |
211 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_close(1,1,:)),'k'), hold on |
212 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_close(2,1,:)),'b') |
213 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_close_ref(1,1,:)),'g') |
214 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_close_simple(1,1,:)),'r') |
215 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_close_fd(1,1,:)),'m') |
216 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_close_td(1,1,:)),'c') |
217 |
| - grid |
218 |
| - xlabel('samples'), ylabel('amplitude') |
219 |
| - axis([0 160 -0.6 0.6]) |
220 |
| - legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',... |
221 |
| - 'timedomain interp') |
222 |
| - title('Interpolation of close HRIRs') |
223 |
| - |
224 |
| -figure |
225 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_dist(1,1,:)),'k'), hold on |
226 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_dist(2,1,:)),'b') |
227 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_dist_ref(1,1,:)),'g') |
228 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_dist_simple(1,1,:)),'r') |
229 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_dist_fd(1,1,:)),'m') |
230 |
| - plot(0:hrtf.API.N-1,squeeze(hrir_dist_td(1,1,:)),'c') |
231 |
| - grid |
232 |
| - xlabel('samples'), ylabel('amplitude') |
233 |
| - axis([0 160 -0.6 0.6]) |
234 |
| - legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',... |
235 |
| - 'timedomain interp') |
236 |
| - title('Interpolation of distant HRIRs') |
237 |
| - |
238 |
| -% magnitude responses |
239 |
| -f = (0:hrtf.API.N-1)/hrtf.API.N*hrtf.Data.SamplingRate; |
240 |
| -figure |
241 |
| - semilogx(f,db(abs(fft(squeeze(hrir_close(1,1,:))))),'k'), hold on |
242 |
| - semilogx(f,db(abs(fft(squeeze(hrir_close(2,1,:))))),'b') |
243 |
| - semilogx(f,db(abs(fft(squeeze(hrir_close_ref(1,1,:))))),'g') |
244 |
| - semilogx(f,db(abs(fft(squeeze(hrir_close_simple(1,1,:))))),'r') |
245 |
| - semilogx(f,db(abs(fft(squeeze(hrir_close_fd(1,1,:))))),'m') |
246 |
| - semilogx(f,db(abs(fft(squeeze(hrir_close_td(1,1,:))))),'c') |
247 |
| - grid |
248 |
| - xlabel('frequency in Hz'), ylabel('amplitude in dB') |
249 |
| - axis([0 hrtf.Data.SamplingRate/2 -60 20]) |
250 |
| - legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',... |
251 |
| - 'timedomain interp','Location','SW') |
252 |
| - title('Interpolation of close HRIRs') |
253 |
| - |
254 |
| -figure |
255 |
| - semilogx(f,db(abs(fft(squeeze(hrir_dist(1,1,:))))),'k'), hold on |
256 |
| - semilogx(f,db(abs(fft(squeeze(hrir_dist(2,1,:))))),'b') |
257 |
| - semilogx(f,db(abs(fft(squeeze(hrir_dist_ref(1,1,:))))),'g') |
258 |
| - semilogx(f,db(abs(fft(squeeze(hrir_dist_simple(1,1,:))))),'r') |
259 |
| - semilogx(f,db(abs(fft(squeeze(hrir_dist_fd(1,1,:))))),'m') |
260 |
| - semilogx(f,db(abs(fft(squeeze(hrir_dist_td(1,1,:))))),'c') |
261 |
| - grid |
262 |
| - xlabel('frequency in Hz'), ylabel('amplitude in dB') |
263 |
| - axis([0 hrtf.Data.SamplingRate/2 -60 20]) |
264 |
| - legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',... |
265 |
| - 'timedomain interp','Location','SW') |
266 |
| - title('Interpolation of distant HRIRs') |
| 207 | +hrir_list = { |
| 208 | + hrir_close(1,1,:) , hrir_dist(1,1,:) |
| 209 | + hrir_close(2,1,:) , hrir_dist(2,1,:) |
| 210 | + hrir_close_ref(1,1,:) , hrir_dist_ref(1,1,:) |
| 211 | + hrir_close_simple(1,1,:), hrir_dist_simple(1,1,:) |
| 212 | + hrir_close_fd(1,1,:) , hrir_dist_fd(1,1,:) |
| 213 | + hrir_close_td(1,1,:) , hrir_dist_td(1,1,:) |
| 214 | + }; % list of HRIRs |
| 215 | + |
| 216 | +col = {'k' 'b' 'g' 'r' 'm' 'c'}; |
| 217 | +titlelabels = {'close', 'distant'}; |
| 218 | +legendpos = {'northeast', 'southwest'}; |
| 219 | + |
| 220 | +t = 0:hrtf.API.N-1; % time-axis in samples |
| 221 | +f = (0:hrtf.API.N-1)/hrtf.API.N*hrtf.Data.SamplingRate; % frequency axis |
| 222 | + |
| 223 | +for pdx=1:2 % impulse responses or magnitude spectrum |
| 224 | + for cdx=1:size(hrir_list,2) |
| 225 | + figure |
| 226 | + for rdx=1:size(hrir_list,1) |
| 227 | + if pdx == 1 |
| 228 | + % impulse responses |
| 229 | + plot(t,squeeze(hrir_list{rdx, cdx}),col{rdx}) |
| 230 | + else |
| 231 | + % magnitude spectra |
| 232 | + mag_spectrum = db(abs(fft(squeeze(hrir_list{rdx, cdx})))); |
| 233 | + semilogx(f(2:end), mag_spectrum(2:end), col{rdx}); |
| 234 | + end |
| 235 | + hold on |
| 236 | + end |
| 237 | + hold off |
| 238 | + |
| 239 | + if pdx == 1 |
| 240 | + % impulse responses |
| 241 | + xlabel('samples') |
| 242 | + ylabel('amplitude') |
| 243 | + axis([0 160 -0.6 0.6]) |
| 244 | + else |
| 245 | + % magnitude spectra |
| 246 | + xlabel('frequency in Hz') |
| 247 | + ylabel('amplitude in dB') |
| 248 | + axis([f(2) hrtf.Data.SamplingRate/2 -60 20]) |
| 249 | + end |
| 250 | + legend('hrir_1','hrir_2','hrir_{ref}','simple interp', ... |
| 251 | + 'freqdomain interp', 'timedomain interp','Location', legendpos{pdx}) |
| 252 | + title(['Interpolation of ' titlelabels{cdx} ' HRIRs']) |
| 253 | + end |
| 254 | +end |
267 | 255 |
|
268 | 256 | status = true;
|
0 commit comments