OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
11 #define _USE_MATH_DEFINES | 11 #define _USE_MATH_DEFINES |
12 | 12 |
13 #include "webrtc/modules/audio_processing/beamformer/covariance_matrix_generator
.h" | 13 #include "webrtc/modules/audio_processing/beamformer/covariance_matrix_generator
.h" |
14 | 14 |
15 #include <cmath> | 15 #include <cmath> |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 namespace { | 18 namespace { |
19 | 19 |
20 float BesselJ0(float x) { | 20 float BesselJ0(float x) { |
21 #if WEBRTC_WIN | 21 #ifdef WEBRTC_WIN |
22 return _j0(x); | 22 return _j0(x); |
23 #else | 23 #else |
24 return j0(x); | 24 return j0(x); |
25 #endif | 25 #endif |
26 } | 26 } |
27 | 27 |
28 // Calculates the Euclidean norm for a row vector. | 28 // Calculates the Euclidean norm for a row vector. |
29 float Norm(const ComplexMatrix<float>& x) { | 29 float Norm(const ComplexMatrix<float>& x) { |
30 RTC_CHECK_EQ(1u, x.num_rows()); | 30 RTC_CHECK_EQ(1u, x.num_rows()); |
31 const size_t length = x.num_columns(); | 31 const size_t length = x.num_columns(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 float distance = std::cos(angle) * geometry[c_ix].x() + | 105 float distance = std::cos(angle) * geometry[c_ix].x() + |
106 std::sin(angle) * geometry[c_ix].y(); | 106 std::sin(angle) * geometry[c_ix].y(); |
107 float phase_shift = -2.f * M_PI * distance * freq_in_hertz / sound_speed; | 107 float phase_shift = -2.f * M_PI * distance * freq_in_hertz / sound_speed; |
108 | 108 |
109 // Euler's formula for mat[0][c_ix] = e^(j * phase_shift). | 109 // Euler's formula for mat[0][c_ix] = e^(j * phase_shift). |
110 mat_els[0][c_ix] = complex<float>(cos(phase_shift), sin(phase_shift)); | 110 mat_els[0][c_ix] = complex<float>(cos(phase_shift), sin(phase_shift)); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 } // namespace webrtc | 114 } // namespace webrtc |
OLD | NEW |