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()); |
68 | 69 |
69 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { | 70 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { |
70 capture_audio_buffer->MergeFrequencyBands(); | 71 capture_audio_buffer->MergeFrequencyBands(); |
71 } | 72 } |
72 } | 73 } |
73 | 74 |
74 int BeamformerSampleRate(int sample_rate_hz) { | 75 int BeamformerSampleRate(int sample_rate_hz) { |
75 return (sample_rate_hz > AudioProcessing::kSampleRate16kHz | 76 return (sample_rate_hz > AudioProcessing::kSampleRate16kHz |
76 ? AudioProcessing::kSampleRate16kHz | 77 ? AudioProcessing::kSampleRate16kHz |
77 : sample_rate_hz); | 78 : sample_rate_hz); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection1) { | 256 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection1) { |
256 const float kOutputReference[] = {0.001318f, -0.001091f, 0.000990f, | 257 const float kOutputReference[] = {0.001318f, -0.001091f, 0.000990f, |
257 0.001318f, -0.001091f, 0.000990f}; | 258 0.001318f, -0.001091f, 0.000990f}; |
258 | 259 |
259 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), | 260 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), |
260 TargetDirection1, kOutputReference); | 261 TargetDirection1, kOutputReference); |
261 } | 262 } |
262 | 263 |
263 TEST(BeamformerBitExactnessTest, | 264 TEST(BeamformerBitExactnessTest, |
264 Stereo16kHz_ArrayGeometry1_TargetDirection1) { | 265 Stereo16kHz_ArrayGeometry1_TargetDirection1) { |
265 const float kOutputReference[] = {0.000064f, 0.000211f, 0.000075f, | 266 const float kOutputReference[] = {0.000046f, 0.000297f, 0.000056f, |
266 0.000064f, 0.000211f, 0.000075f}; | 267 0.000046f, 0.000297f, 0.000056f}; |
267 | 268 |
268 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), | 269 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), |
269 TargetDirection1, kOutputReference); | 270 TargetDirection1, kOutputReference); |
270 } | 271 } |
271 | 272 |
272 TEST(BeamformerBitExactnessTest, | 273 TEST(BeamformerBitExactnessTest, |
273 Stereo32kHz_ArrayGeometry1_TargetDirection1) { | 274 Stereo32kHz_ArrayGeometry1_TargetDirection1) { |
274 const float kOutputReference[] = {0.000183f, 0.000183f, 0.000183f, | 275 const float kOutputReference[] = {0.000183f, 0.000183f, 0.000183f, |
275 0.000183f, 0.000183f, 0.000183f}; | 276 0.000183f, 0.000183f, 0.000183f}; |
276 | 277 |
277 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), | 278 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), |
278 TargetDirection1, kOutputReference); | 279 TargetDirection1, kOutputReference); |
279 } | 280 } |
280 | 281 |
281 TEST(BeamformerBitExactnessTest, | 282 TEST(BeamformerBitExactnessTest, |
282 Stereo48kHz_ArrayGeometry1_TargetDirection1) { | 283 Stereo48kHz_ArrayGeometry1_TargetDirection1) { |
283 const float kOutputReference[] = {0.000155f, 0.000152f, 0.000159f, | 284 const float kOutputReference[] = {0.000228f, 0.000224f, 0.000231f, |
284 0.000155f, 0.000152f, 0.000159f}; | 285 0.000228f, 0.000224f, 0.000231f}; |
285 | 286 |
286 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), | 287 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), |
287 TargetDirection1, kOutputReference); | 288 TargetDirection1, kOutputReference); |
288 } | 289 } |
289 | 290 |
290 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in | 291 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in |
291 // this setup. | 292 // this setup. |
292 TEST(BeamformerBitExactnessTest, | 293 TEST(BeamformerBitExactnessTest, |
293 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection2) { | 294 DISABLED_Stereo8kHz_ArrayGeometry1_TargetDirection2) { |
294 const float kOutputReference[] = {0.001144f, -0.001026f, 0.001074f, | 295 const float kOutputReference[] = {0.001144f, -0.001026f, 0.001074f, |
295 -0.016205f, -0.007324f, -0.015656f}; | 296 -0.016205f, -0.007324f, -0.015656f}; |
296 | 297 |
297 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), | 298 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(1), |
298 TargetDirection2, kOutputReference); | 299 TargetDirection2, kOutputReference); |
299 } | 300 } |
300 | 301 |
301 TEST(BeamformerBitExactnessTest, | 302 TEST(BeamformerBitExactnessTest, |
302 Stereo16kHz_ArrayGeometry1_TargetDirection2) { | 303 Stereo16kHz_ArrayGeometry1_TargetDirection2) { |
303 const float kOutputReference[] = {0.001144f, -0.001026f, 0.001074f, | 304 const float kOutputReference[] = {0.001807f, -0.001761f, 0.001908f, |
304 0.001144f, -0.001026f, 0.001074f}; | 305 0.001807f, -0.001761f, 0.001908f}; |
305 | 306 |
306 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), | 307 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(1), |
307 TargetDirection2, kOutputReference); | 308 TargetDirection2, kOutputReference); |
308 } | 309 } |
309 | 310 |
310 TEST(BeamformerBitExactnessTest, | 311 TEST(BeamformerBitExactnessTest, |
311 Stereo32kHz_ArrayGeometry1_TargetDirection2) { | 312 Stereo32kHz_ArrayGeometry1_TargetDirection2) { |
312 const float kOutputReference[] = {0.000732f, -0.000397f, 0.000610f, | 313 const float kOutputReference[] = {0.000916f, -0.000641f, 0.000122f, |
313 0.000732f, -0.000397f, 0.000610f}; | 314 0.000916f, -0.000641f, 0.000122f}; |
314 | 315 |
315 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), | 316 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(1), |
316 TargetDirection2, kOutputReference); | 317 TargetDirection2, kOutputReference); |
317 } | 318 } |
318 | 319 |
319 TEST(BeamformerBitExactnessTest, | 320 TEST(BeamformerBitExactnessTest, |
320 Stereo48kHz_ArrayGeometry1_TargetDirection2) { | 321 Stereo48kHz_ArrayGeometry1_TargetDirection2) { |
321 const float kOutputReference[] = {0.000106f, -0.000464f, 0.000188f, | 322 const float kOutputReference[] = {0.000274f, -0.000307f, 0.000280f, |
322 0.000106f, -0.000464f, 0.000188f}; | 323 0.000274f, -0.000307f, 0.000280f}; |
323 | 324 |
324 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), | 325 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(1), |
325 TargetDirection2, kOutputReference); | 326 TargetDirection2, kOutputReference); |
326 } | 327 } |
327 | 328 |
328 TEST(BeamformerBitExactnessTest, | 329 TEST(BeamformerBitExactnessTest, |
329 Stereo8kHz_ArrayGeometry2_TargetDirection2) { | 330 Stereo8kHz_ArrayGeometry2_TargetDirection2) { |
330 const float kOutputReference[] = {-0.000649f, 0.000576f, -0.000148f, | 331 const float kOutputReference[] = {-0.001365f, -0.000137f, -0.000297f, |
331 -0.000649f, 0.000576f, -0.000148f}; | 332 -0.001365f, -0.000137f, -0.000297f}; |
332 | 333 |
333 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(2), | 334 RunBitExactnessTest(AudioProcessing::kSampleRate8kHz, CreateArrayGeometry(2), |
334 TargetDirection2, kOutputReference); | 335 TargetDirection2, kOutputReference); |
335 } | 336 } |
336 | 337 |
337 TEST(BeamformerBitExactnessTest, | 338 TEST(BeamformerBitExactnessTest, |
338 Stereo16kHz_ArrayGeometry2_TargetDirection2) { | 339 Stereo16kHz_ArrayGeometry2_TargetDirection2) { |
339 const float kOutputReference[] = {0.000808f, -0.000695f, 0.000739f, | 340 const float kOutputReference[] = {0.001243f, -0.001196f, 0.001312f, |
340 0.000808f, -0.000695f, 0.000739f}; | 341 0.001243f, -0.001196f, 0.001312f}; |
341 | 342 |
342 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(2), | 343 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(2), |
343 TargetDirection2, kOutputReference); | 344 TargetDirection2, kOutputReference); |
344 } | 345 } |
345 | 346 |
346 TEST(BeamformerBitExactnessTest, | 347 TEST(BeamformerBitExactnessTest, |
347 Stereo32kHz_ArrayGeometry2_TargetDirection2) { | 348 Stereo32kHz_ArrayGeometry2_TargetDirection2) { |
348 const float kOutputReference[] = {0.000580f, -0.000183f, 0.000458f, | 349 const float kOutputReference[] = {0.000671f, -0.000366f, 0.000122f, |
349 0.000580f, -0.000183f, 0.000458f}; | 350 0.000671f, -0.000366f, 0.000122f}; |
350 | 351 |
351 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(2), | 352 RunBitExactnessTest(AudioProcessing::kSampleRate32kHz, CreateArrayGeometry(2), |
352 TargetDirection2, kOutputReference); | 353 TargetDirection2, kOutputReference); |
353 } | 354 } |
354 | 355 |
355 TEST(BeamformerBitExactnessTest, | 356 TEST(BeamformerBitExactnessTest, |
356 Stereo48kHz_ArrayGeometry2_TargetDirection2) { | 357 Stereo48kHz_ArrayGeometry2_TargetDirection2) { |
357 const float kOutputReference[] = {0.000075f, -0.000288f, 0.000156f, | 358 const float kOutputReference[] = {0.000135f, -0.000236f, 0.000179f, |
358 0.000075f, -0.000288f, 0.000156f}; | 359 0.000135f, -0.000236f, 0.000179f}; |
359 | 360 |
360 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(2), | 361 RunBitExactnessTest(AudioProcessing::kSampleRate48kHz, CreateArrayGeometry(2), |
361 TargetDirection2, kOutputReference); | 362 TargetDirection2, kOutputReference); |
362 } | 363 } |
363 | 364 |
364 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in | 365 // TODO(peah): Investigate why the nonlinear_beamformer.cc causes a DCHECK in |
365 // this setup. | 366 // this setup. |
366 TEST(BeamformerBitExactnessTest, | 367 TEST(BeamformerBitExactnessTest, |
367 DISABLED_Stereo16kHz_ArrayGeometry3_TargetDirection1) { | 368 DISABLED_Stereo16kHz_ArrayGeometry3_TargetDirection1) { |
368 const float kOutputReference[] = {-0.000161f, 0.000171f, -0.000096f, | 369 const float kOutputReference[] = {-0.000161f, 0.000171f, -0.000096f, |
369 0.001007f, 0.000427f, 0.000977f}; | 370 0.001007f, 0.000427f, 0.000977f}; |
370 | 371 |
371 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(3), | 372 RunBitExactnessTest(AudioProcessing::kSampleRate16kHz, CreateArrayGeometry(3), |
372 TargetDirection1, kOutputReference); | 373 TargetDirection1, kOutputReference); |
373 } | 374 } |
374 | 375 |
375 } // namespace webrtc | 376 } // namespace webrtc |
OLD | NEW |