OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void ProcessOneFrame(int sample_rate_hz, | 58 void ProcessOneFrame(int sample_rate_hz, |
59 AudioBuffer* capture_audio_buffer, | 59 AudioBuffer* capture_audio_buffer, |
60 Beamformer<float>* beamformer) { | 60 Beamformer<float>* beamformer) { |
61 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { | 61 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { |
62 capture_audio_buffer->SplitIntoFrequencyBands(); | 62 capture_audio_buffer->SplitIntoFrequencyBands(); |
63 } | 63 } |
64 | 64 |
65 beamformer->ProcessChunk(*capture_audio_buffer->split_data_f(), | 65 beamformer->ProcessChunk(*capture_audio_buffer->split_data_f(), |
66 capture_audio_buffer->split_data_f()); | 66 capture_audio_buffer->split_data_f()); |
67 capture_audio_buffer->set_num_channels(1); | 67 capture_audio_buffer->set_num_channels(1); |
| 68 beamformer->PostFilter(*capture_audio_buffer->split_data_f(), |
| 69 capture_audio_buffer->split_data_f()); |
68 | 70 |
69 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { | 71 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { |
70 capture_audio_buffer->MergeFrequencyBands(); | 72 capture_audio_buffer->MergeFrequencyBands(); |
71 } | 73 } |
72 } | 74 } |
73 | 75 |
74 int BeamformerSampleRate(int sample_rate_hz) { | 76 int BeamformerSampleRate(int sample_rate_hz) { |
75 return (sample_rate_hz > AudioProcessing::kSampleRate16kHz | 77 return (sample_rate_hz > AudioProcessing::kSampleRate16kHz |
76 ? AudioProcessing::kSampleRate16kHz | 78 ? AudioProcessing::kSampleRate16kHz |
77 : sample_rate_hz); | 79 : sample_rate_hz); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection1) { | 257 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection1) { |
256 const float kOutputReference[] = {0.001318f, -0.001091f, 0.000990f, | 258 const float kOutputReference[] = {0.001318f, -0.001091f, 0.000990f, |
257 0.001318f, -0.001091f, 0.000990f}; | 259 0.001318f, -0.001091f, 0.000990f}; |
258 | 260 |
259 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), | 261 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), |
260 TargetDirection1, kOutputReference); | 262 TargetDirection1, kOutputReference); |
261 } | 263 } |
262 | 264 |
263 TEST(BeamformerBitExactnessTest, | 265 TEST(BeamformerBitExactnessTest, |
264 Stereo16kHz_ArrayGeometry1_TargetDirection1) { | 266 Stereo16kHz_ArrayGeometry1_TargetDirection1) { |
265 const float kOutputReference[] = {0.000064f, 0.000211f, 0.000075f, | 267 const float kOutputReference[] = {0.000046f, 0.000297f, 0.000056f, |
266 0.000064f, 0.000211f, 0.000075f}; | 268 0.000046f, 0.000297f, 0.000056f}; |
267 | 269 |
268 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), | 270 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), |
269 TargetDirection1, kOutputReference); | 271 TargetDirection1, kOutputReference); |
270 } | 272 } |
271 | 273 |
272 TEST(BeamformerBitExactnessTest, | 274 TEST(BeamformerBitExactnessTest, |
273 Stereo32kHz_ArrayGeometry1_TargetDirection1) { | 275 Stereo32kHz_ArrayGeometry1_TargetDirection1) { |
274 const float kOutputReference[] = {0.000183f, 0.000183f, 0.000183f, | 276 const float kOutputReference[] = {0.000183f, 0.000183f, 0.000183f, |
275 0.000183f, 0.000183f, 0.000183f}; | 277 0.000183f, 0.000183f, 0.000183f}; |
276 | 278 |
277 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), | 279 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), |
278 TargetDirection1, kOutputReference); | 280 TargetDirection1, kOutputReference); |
279 } | 281 } |
280 | 282 |
281 TEST(BeamformerBitExactnessTest, | 283 TEST(BeamformerBitExactnessTest, |
282 Stereo48kHz_ArrayGeometry1_TargetDirection1) { | 284 Stereo48kHz_ArrayGeometry1_TargetDirection1) { |
283 const float kOutputReference[] = {0.000155f, 0.000152f, 0.000159f, | 285 const float kOutputReference[] = {0.000228f, 0.000224f, 0.000231f, |
284 0.000155f, 0.000152f, 0.000159f}; | 286 0.000228f, 0.000224f, 0.000231f}; |
285 | 287 |
286 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), | 288 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), |
287 TargetDirection1, kOutputReference); | 289 TargetDirection1, kOutputReference); |
288 } | 290 } |
289 | 291 |
290 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in | 292 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in |
291 // this setup. | 293 // this setup. |
292 TEST(BeamformerBitExactnessTest, | 294 TEST(BeamformerBitExactnessTest, |
293 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection2) { | 295 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection2) { |
294 const float kOutputReference[] = {0.001144f, -0.001026f, 0.001074f, | 296 const float kOutputReference[] = {0.001144f, -0.001026f, 0.001074f, |
295 -0.016205f, -0.007324f, -0.015656f}; | 297 -0.016205f, -0.007324f, -0.015656f}; |
296 | 298 |
297 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), | 299 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), |
298 TargetDirection2, kOutputReference); | 300 TargetDirection2, kOutputReference); |
299 } | 301 } |
300 | 302 |
301 TEST(BeamformerBitExactnessTest, | 303 TEST(BeamformerBitExactnessTest, |
302 Stereo16kHz_ArrayGeometry1_TargetDirection2) { | 304 Stereo16kHz_ArrayGeometry1_TargetDirection2) { |
303 const float kOutputReference[] = {0.001144f, -0.001026f, 0.001074f, | 305 const float kOutputReference[] = {0.001807f, -0.001761f, 0.001908f, |
304 0.001144f, -0.001026f, 0.001074f}; | 306 0.001807f, -0.001761f, 0.001908f}; |
305 | 307 |
306 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), | 308 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), |
307 TargetDirection2, kOutputReference); | 309 TargetDirection2, kOutputReference); |
308 } | 310 } |
309 | 311 |
310 TEST(BeamformerBitExactnessTest, | 312 TEST(BeamformerBitExactnessTest, |
311 Stereo32kHz_ArrayGeometry1_TargetDirection2) { | 313 Stereo32kHz_ArrayGeometry1_TargetDirection2) { |
312 const float kOutputReference[] = {0.000732f, -0.000397f, 0.000610f, | 314 const float kOutputReference[] = {0.000916f, -0.000641f, 0.000122f, |
313 0.000732f, -0.000397f, 0.000610f}; | 315 0.000916f, -0.000641f, 0.000122f}; |
314 | 316 |
315 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), | 317 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), |
316 TargetDirection2, kOutputReference); | 318 TargetDirection2, kOutputReference); |
317 } | 319 } |
318 | 320 |
319 TEST(BeamformerBitExactnessTest, | 321 TEST(BeamformerBitExactnessTest, |
320 Stereo48kHz_ArrayGeometry1_TargetDirection2) { | 322 Stereo48kHz_ArrayGeometry1_TargetDirection2) { |
321 const float kOutputReference[] = {0.000106f, -0.000464f, 0.000188f, | 323 const float kOutputReference[] = {0.000274f, -0.000307f, 0.000280f, |
322 0.000106f, -0.000464f, 0.000188f}; | 324 0.000274f, -0.000307f, 0.000280f}; |
323 | 325 |
324 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), | 326 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), |
325 TargetDirection2, kOutputReference); | 327 TargetDirection2, kOutputReference); |
326 } | 328 } |
327 | 329 |
328 TEST(BeamformerBitExactnessTest, | 330 TEST(BeamformerBitExactnessTest, |
329 Stereo8kHz_ArrayGeometry2_TargetDirection2) { | 331 Stereo8kHz_ArrayGeometry2_TargetDirection2) { |
330 const float kOutputReference[] = {-0.000649f, 0.000576f, -0.000148f, | 332 const float kOutputReference[] = {-0.001365f, -0.000137f, -0.000297f, |
331 -0.000649f, 0.000576f, -0.000148f}; | 333 -0.001365f, -0.000137f, -0.000297f}; |
332 | 334 |
333 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(2), | 335 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(2), |
334 TargetDirection2, kOutputReference); | 336 TargetDirection2, kOutputReference); |
335 } | 337 } |
336 | 338 |
337 TEST(BeamformerBitExactnessTest, | 339 TEST(BeamformerBitExactnessTest, |
338 Stereo16kHz_ArrayGeometry2_TargetDirection2) { | 340 Stereo16kHz_ArrayGeometry2_TargetDirection2) { |
339 const float kOutputReference[] = {0.000808f, -0.000695f, 0.000739f, | 341 const float kOutputReference[] = {0.001243f, -0.001196f, 0.001312f, |
340 0.000808f, -0.000695f, 0.000739f}; | 342 0.001243f, -0.001196f, 0.001312f}; |
341 | 343 |
342 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(2), | 344 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(2), |
343 TargetDirection2, kOutputReference); | 345 TargetDirection2, kOutputReference); |
344 } | 346 } |
345 | 347 |
346 TEST(BeamformerBitExactnessTest, | 348 TEST(BeamformerBitExactnessTest, |
347 Stereo32kHz_ArrayGeometry2_TargetDirection2) { | 349 Stereo32kHz_ArrayGeometry2_TargetDirection2) { |
348 const float kOutputReference[] = {0.000580f, -0.000183f, 0.000458f, | 350 const float kOutputReference[] = {0.000671f, -0.000366f, 0.000122f, |
349 0.000580f, -0.000183f, 0.000458f}; | 351 0.000671f, -0.000366f, 0.000122f}; |
350 | 352 |
351 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(2), | 353 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(2), |
352 TargetDirection2, kOutputReference); | 354 TargetDirection2, kOutputReference); |
353 } | 355 } |
354 | 356 |
355 TEST(BeamformerBitExactnessTest, | 357 TEST(BeamformerBitExactnessTest, |
356 Stereo48kHz_ArrayGeometry2_TargetDirection2) { | 358 Stereo48kHz_ArrayGeometry2_TargetDirection2) { |
357 const float kOutputReference[] = {0.000075f, -0.000288f, 0.000156f, | 359 const float kOutputReference[] = {0.000135f, -0.000236f, 0.000179f, |
358 0.000075f, -0.000288f, 0.000156f}; | 360 0.000135f, -0.000236f, 0.000179f}; |
359 | 361 |
360 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(2), | 362 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(2), |
361 TargetDirection2, kOutputReference); | 363 TargetDirection2, kOutputReference); |
362 } | 364 } |
363 | 365 |
364 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in | 366 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in |
365 // this setup. | 367 // this setup. |
366 TEST(BeamformerBitExactnessTest, | 368 TEST(BeamformerBitExactnessTest, |
367 DISABLED_Stereo16kHz_ArrayGeometry3_TargetDirection1) { | 369 DISABLED_Stereo16kHz_ArrayGeometry3_TargetDirection1) { |
368 const float kOutputReference[] = {-0.000161f, 0.000171f, -0.000096f, | 370 const float kOutputReference[] = {-0.000161f, 0.000171f, -0.000096f, |
369 0.001007f, 0.000427f, 0.000977f}; | 371 0.001007f, 0.000427f, 0.000977f}; |
370 | 372 |
371 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(3), | 373 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(3), |
372 TargetDirection1, kOutputReference); | 374 TargetDirection1, kOutputReference); |
373 } | 375 } |
374 | 376 |
375 } // namespace webrtc | 377 } // namespace webrtc |
OLD | NEW |