|
80 | 80 | % interpolation points
|
81 | 81 | x0 = [1 3; 0 0; 0 0]/180*pi;
|
82 | 82 | % weights (for target point: xs = [2; 0; 0]/180*pi )
|
83 |
| -weights = [.5 .5]; |
| 83 | +weights = [.5; .5]; |
84 | 84 | N = 50; %length impulse responses
|
85 | 85 |
|
86 | 86 | % 1. Interpolate between Dirac impulses with one sample in between
|
|
97 | 97 | h_int1_simple = interpolate_ir(irs1,weights,conf);
|
98 | 98 | conf.ir.interpolationmethod = 'freqdomain';
|
99 | 99 | h_int1_fd = interpolate_ir(irs1,weights,conf);
|
| 100 | +conf.ir.interpolationmethod = 'timedomain'; |
| 101 | +h_int1_td = interpolate_ir(irs1,weights,conf); |
100 | 102 |
|
101 | 103 | % 2. Interpolate between neighbouring Dirac impulses at impulse reponse start
|
102 | 104 | h1 = zeros(1,N);
|
|
112 | 114 | h_int2_simple = interpolate_ir(irs2,weights,conf);
|
113 | 115 | conf.ir.interpolationmethod = 'freqdomain';
|
114 | 116 | h_int2_fd = interpolate_ir(irs2,weights,conf);
|
| 117 | +conf.ir.interpolationmethod = 'timedomain'; |
| 118 | +h_int2_td = interpolate_ir(irs2,weights,conf); |
115 | 119 |
|
116 | 120 | % 3. Interpolate between neighbouring Dirac impulses in middle of impulse response
|
117 | 121 | h4 = zeros(1,N);
|
|
127 | 131 | h_int3_simple = interpolate_ir(irs3,weights,conf);
|
128 | 132 | conf.ir.interpolationmethod = 'freqdomain';
|
129 | 133 | h_int3_fd = interpolate_ir(irs3,weights,conf);
|
| 134 | +conf.ir.interpolationmethod = 'timedomain'; |
| 135 | +h_int3_td = interpolate_ir(irs3,weights,conf); |
130 | 136 |
|
131 | 137 | % Plots
|
132 | 138 | % impulse responses
|
|
135 | 141 | plot(0:N-1,squeeze(irs1(2,1,:)),'b')
|
136 | 142 | plot(0:N-1,squeeze(h_int1_simple(1,1,:)),'r')
|
137 | 143 | plot(0:N-1,squeeze(h_int1_fd(1,1,:)),'m')
|
| 144 | + plot(0:N-1,squeeze(h_int1_td(1,1,:)),'c') |
138 | 145 | grid
|
139 | 146 | xlabel('samples'), ylabel('amplitude')
|
140 |
| - legend('h_1','h_2','simple interp','freqdomain interp') |
| 147 | + legend('h_1','h_2','simple interp','freqdomain interp','timedomain interp') |
141 | 148 | title('Interpolation between Dirac impulses with one sample in between')
|
142 | 149 |
|
143 | 150 | figure
|
144 | 151 | plot(0:N-1,squeeze(irs2(1,1,:)),'k'), hold on
|
145 | 152 | plot(0:N-1,squeeze(irs2(2,1,:)),'b')
|
146 | 153 | plot(0:N-1,squeeze(h_int2_simple(1,1,:)),'r')
|
147 | 154 | plot(0:N-1,squeeze(h_int2_fd(1,1,:)),'m')
|
| 155 | + plot(0:N-1,squeeze(h_int2_td(1,1,:)),'c') |
148 | 156 | grid
|
149 | 157 | xlabel('samples'), ylabel('amplitude')
|
150 |
| - legend('h_1','h_2','simple interp','freqdomain interp') |
| 158 | + legend('h_1','h_2','simple interp','freqdomain interp','timedomain interp') |
151 | 159 | title('Interpolation of neighbouring Dirac impulses at impulse response start')
|
152 | 160 |
|
153 | 161 | figure
|
154 | 162 | plot(0:N-1,squeeze(irs3(1,1,:)),'k'), hold on
|
155 | 163 | plot(0:N-1,squeeze(irs3(2,1,:)),'b')
|
156 | 164 | plot(0:N-1,squeeze(h_int3_simple(1,1,:)),'r')
|
157 | 165 | plot(0:N-1,squeeze(h_int3_fd(1,1,:)),'m')
|
| 166 | + plot(0:N-1,squeeze(h_int3_td(1,1,:)),'c') |
158 | 167 | grid
|
159 | 168 | xlabel('samples'), ylabel('amplitude')
|
160 |
| - legend('h_1','h_2','simple interp','freqdomain interp') |
| 169 | + legend('h_1','h_2','simple interp','freqdomain interp','timedomain interp') |
161 | 170 | title('Interpolation of neighbouring Dirac impulses in middle of impulse response')
|
162 | 171 |
|
163 | 172 |
|
|
168 | 177 | idx2 = 183; %index for 2° azimuth
|
169 | 178 | x0_close = [hrtf.SourcePosition(idx0,:).' hrtf.SourcePosition(idx2,:).']/180*pi;
|
170 | 179 | % weights (for target point: xs_close = hrtf.SourcePosition(idx1,:).'/180*pi )
|
171 |
| -weights_close = [.5 .5]; |
| 180 | +weights_close = [.5; .5]; |
172 | 181 | hrir_close = [hrtf.Data.IR(idx0,:,:); hrtf.Data.IR(idx2,:,:)];
|
173 | 182 | hrir_close_ref = hrtf.Data.IR(idx1,:,:);
|
174 | 183 |
|
175 | 184 | conf.ir.interpolationmethod = 'simple';
|
176 | 185 | hrir_close_simple = interpolate_ir(hrir_close,weights_close,conf);
|
177 | 186 | conf.ir.interpolationmethod = 'freqdomain';
|
178 | 187 | hrir_close_fd = interpolate_ir(hrir_close,weights_close,conf);
|
| 188 | +conf.ir.interpolationmethod = 'timedomain'; |
| 189 | +hrir_close_td = interpolate_ir(hrir_close,weights_close,conf); |
179 | 190 |
|
180 | 191 | % 2. Interpolate between distant HRIRs
|
181 | 192 | idx0 = 181; %index for 0° azimuth
|
182 | 193 | idx30 = 211; %index for 30° azimuth
|
183 | 194 | idx60 = 241; %index for 60° azimuth
|
184 | 195 | x0_dist = [hrtf.SourcePosition(idx0,:).' hrtf.SourcePosition(idx60,:).']/180*pi;
|
185 | 196 | % weights (for target point: xs_dist = hrtf.SourcePosition(idx30,:).'/180*pi )
|
186 |
| -weights_dist = [.5 .5]; |
| 197 | +weights_dist = [.5; .5]; |
187 | 198 | hrir_dist = [hrtf.Data.IR(idx0,:,:); hrtf.Data.IR(idx60,:,:)];
|
188 | 199 | hrir_dist_ref = hrtf.Data.IR(idx30,:,:);
|
189 | 200 |
|
190 | 201 | conf.ir.interpolationmethod = 'simple';
|
191 | 202 | hrir_dist_simple = interpolate_ir(hrir_dist,weights_dist,conf);
|
192 | 203 | conf.ir.interpolationmethod = 'freqdomain';
|
193 | 204 | hrir_dist_fd = interpolate_ir(hrir_dist,weights_dist,conf);
|
| 205 | +conf.ir.interpolationmethod = 'timedomain'; |
| 206 | +hrir_dist_td = interpolate_ir(hrir_dist,weights_dist,conf); |
194 | 207 |
|
195 | 208 | % Plots
|
196 | 209 | % impulse responses
|
|
200 | 213 | plot(0:hrtf.API.N-1,squeeze(hrir_close_ref(1,1,:)),'g')
|
201 | 214 | plot(0:hrtf.API.N-1,squeeze(hrir_close_simple(1,1,:)),'r')
|
202 | 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') |
203 | 217 | grid
|
204 | 218 | xlabel('samples'), ylabel('amplitude')
|
205 | 219 | axis([0 160 -0.6 0.6])
|
206 |
| - legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp') |
| 220 | + legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',... |
| 221 | + 'timedomain interp') |
207 | 222 | title('Interpolation of close HRIRs')
|
208 | 223 |
|
209 | 224 | figure
|
|
212 | 227 | plot(0:hrtf.API.N-1,squeeze(hrir_dist_ref(1,1,:)),'g')
|
213 | 228 | plot(0:hrtf.API.N-1,squeeze(hrir_dist_simple(1,1,:)),'r')
|
214 | 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') |
215 | 231 | grid
|
216 | 232 | xlabel('samples'), ylabel('amplitude')
|
217 | 233 | axis([0 160 -0.6 0.6])
|
218 |
| - legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp') |
| 234 | + legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',... |
| 235 | + 'timedomain interp') |
219 | 236 | title('Interpolation of distant HRIRs')
|
220 | 237 |
|
221 | 238 | % magnitude responses
|
|
226 | 243 | semilogx(f,db(abs(fft(squeeze(hrir_close_ref(1,1,:))))),'g')
|
227 | 244 | semilogx(f,db(abs(fft(squeeze(hrir_close_simple(1,1,:))))),'r')
|
228 | 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') |
229 | 247 | grid
|
230 | 248 | xlabel('frequency in Hz'), ylabel('amplitude in dB')
|
231 | 249 | axis([0 hrtf.Data.SamplingRate/2 -60 20])
|
232 | 250 | legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',...
|
233 |
| - 'Location','SW') |
| 251 | + 'timedomain interp','Location','SW') |
234 | 252 | title('Interpolation of close HRIRs')
|
235 | 253 |
|
236 | 254 | figure
|
|
239 | 257 | semilogx(f,db(abs(fft(squeeze(hrir_dist_ref(1,1,:))))),'g')
|
240 | 258 | semilogx(f,db(abs(fft(squeeze(hrir_dist_simple(1,1,:))))),'r')
|
241 | 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') |
242 | 261 | grid
|
243 | 262 | xlabel('frequency in Hz'), ylabel('amplitude in dB')
|
244 | 263 | axis([0 hrtf.Data.SamplingRate/2 -60 20])
|
245 | 264 | legend('hrir_1','hrir_2','hrir_{ref}','simple interp','freqdomain interp',...
|
246 |
| - 'Location','SW') |
| 265 | + 'timedomain interp','Location','SW') |
247 | 266 | title('Interpolation of distant HRIRs')
|
248 | 267 |
|
249 | 268 | status = true;
|
0 commit comments