OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 int16_t temp_val_high = ((coeff2_ * sample_history2_[1] + 8192) >> 14) | 188 int16_t temp_val_high = ((coeff2_ * sample_history2_[1] + 8192) >> 14) |
189 - sample_history2_[0]; | 189 - sample_history2_[0]; |
190 | 190 |
191 // Update recursion memory. | 191 // Update recursion memory. |
192 sample_history1_[0] = sample_history1_[1]; | 192 sample_history1_[0] = sample_history1_[1]; |
193 sample_history1_[1] = temp_val_low; | 193 sample_history1_[1] = temp_val_low; |
194 sample_history2_[0] = sample_history2_[1]; | 194 sample_history2_[0] = sample_history2_[1]; |
195 sample_history2_[1] = temp_val_high; | 195 sample_history2_[1] = temp_val_high; |
196 | 196 |
197 // Attenuate the low frequency tone 3 dB. | 197 // Attenuate the low frequency tone 3 dB. |
198 int32_t temp_val = kAmpMultiplier * temp_val_low + (temp_val_high << 15); | 198 int32_t temp_val = |
| 199 kAmpMultiplier * temp_val_low + temp_val_high * (1 << 15); |
199 // Normalize the signal to Q14 with proper rounding. | 200 // Normalize the signal to Q14 with proper rounding. |
200 temp_val = (temp_val + 16384) >> 15; | 201 temp_val = (temp_val + 16384) >> 15; |
201 // Scale the signal to correct volume. | 202 // Scale the signal to correct volume. |
202 (*output)[0][i] = | 203 (*output)[0][i] = |
203 static_cast<int16_t>((temp_val * amplitude_ + 8192) >> 14); | 204 static_cast<int16_t>((temp_val * amplitude_ + 8192) >> 14); |
204 } | 205 } |
205 // Copy first channel to all other channels. | 206 // Copy first channel to all other channels. |
206 for (size_t channel = 1; channel < output->Channels(); ++channel) { | 207 for (size_t channel = 1; channel < output->Channels(); ++channel) { |
207 output->CopyChannel(0, channel); | 208 output->CopyChannel(0, channel); |
208 } | 209 } |
209 | 210 |
210 return static_cast<int>(num_samples); | 211 return static_cast<int>(num_samples); |
211 } | 212 } |
212 | 213 |
213 bool DtmfToneGenerator::initialized() const { | 214 bool DtmfToneGenerator::initialized() const { |
214 return initialized_; | 215 return initialized_; |
215 } | 216 } |
216 | 217 |
217 } // namespace webrtc | 218 } // namespace webrtc |
OLD | NEW |