| 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 12 matching lines...) Expand all Loading... |
| 23 0.3038f, 0.3165f, 0.3291f, 0.3418f, 0.3544f, 0.3671f, 0.3797f, 0.3924f, | 23 0.3038f, 0.3165f, 0.3291f, 0.3418f, 0.3544f, 0.3671f, 0.3797f, 0.3924f, |
| 24 0.4051f, 0.4177f, 0.4304f, 0.4430f, 0.4557f, 0.4684f, 0.4810f, 0.4937f, | 24 0.4051f, 0.4177f, 0.4304f, 0.4430f, 0.4557f, 0.4684f, 0.4810f, 0.4937f, |
| 25 0.5063f, 0.5190f, 0.5316f, 0.5443f, 0.5570f, 0.5696f, 0.5823f, 0.5949f, | 25 0.5063f, 0.5190f, 0.5316f, 0.5443f, 0.5570f, 0.5696f, 0.5823f, 0.5949f, |
| 26 0.6076f, 0.6203f, 0.6329f, 0.6456f, 0.6582f, 0.6709f, 0.6835f, 0.6962f, | 26 0.6076f, 0.6203f, 0.6329f, 0.6456f, 0.6582f, 0.6709f, 0.6835f, 0.6962f, |
| 27 0.7089f, 0.7215f, 0.7342f, 0.7468f, 0.7595f, 0.7722f, 0.7848f, 0.7975f, | 27 0.7089f, 0.7215f, 0.7342f, 0.7468f, 0.7595f, 0.7722f, 0.7848f, 0.7975f, |
| 28 0.8101f, 0.8228f, 0.8354f, 0.8481f, 0.8608f, 0.8734f, 0.8861f, 0.8987f, | 28 0.8101f, 0.8228f, 0.8354f, 0.8481f, 0.8608f, 0.8734f, 0.8861f, 0.8987f, |
| 29 0.9114f, 0.9241f, 0.9367f, 0.9494f, 0.9620f, 0.9747f, 0.9873f, 1.0000f}; | 29 0.9114f, 0.9241f, 0.9367f, 0.9494f, 0.9620f, 0.9747f, 0.9873f, 1.0000f}; |
| 30 const size_t kRampSize = sizeof(kRampArray) / sizeof(kRampArray[0]); | 30 const size_t kRampSize = sizeof(kRampArray) / sizeof(kRampArray[0]); |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 uint32_t NewMixerCalculateEnergy(const AudioFrame& audio_frame) { | 33 uint32_t AudioMixerCalculateEnergy(const AudioFrame& audio_frame) { |
| 34 uint32_t energy = 0; | 34 uint32_t energy = 0; |
| 35 for (size_t position = 0; position < audio_frame.samples_per_channel_; | 35 for (size_t position = 0; position < audio_frame.samples_per_channel_; |
| 36 position++) { | 36 position++) { |
| 37 // TODO(andrew): this can easily overflow. | 37 // TODO(aleloi): This can overflow. Convert to floats. |
| 38 energy += audio_frame.data_[position] * audio_frame.data_[position]; | 38 energy += audio_frame.data_[position] * audio_frame.data_[position]; |
| 39 } | 39 } |
| 40 return energy; | 40 return energy; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void NewMixerRampIn(AudioFrame* audio_frame) { | 43 void NewMixerRampIn(AudioFrame* audio_frame) { |
| 44 assert(kRampSize <= audio_frame->samples_per_channel_); | 44 assert(kRampSize <= audio_frame->samples_per_channel_); |
| 45 for (size_t i = 0; i < kRampSize; i++) { | 45 for (size_t i = 0; i < kRampSize; i++) { |
| 46 audio_frame->data_[i] = | 46 audio_frame->data_[i] = |
| 47 static_cast<int16_t>(kRampArray[i] * audio_frame->data_[i]); | 47 static_cast<int16_t>(kRampArray[i] * audio_frame->data_[i]); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void NewMixerRampOut(AudioFrame* audio_frame) { | 51 void NewMixerRampOut(AudioFrame* audio_frame) { |
| 52 assert(kRampSize <= audio_frame->samples_per_channel_); | 52 assert(kRampSize <= audio_frame->samples_per_channel_); |
| 53 for (size_t i = 0; i < kRampSize; i++) { | 53 for (size_t i = 0; i < kRampSize; i++) { |
| 54 const size_t kRampPos = kRampSize - 1 - i; | 54 const size_t kRampPos = kRampSize - 1 - i; |
| 55 audio_frame->data_[i] = | 55 audio_frame->data_[i] = |
| 56 static_cast<int16_t>(kRampArray[kRampPos] * audio_frame->data_[i]); | 56 static_cast<int16_t>(kRampArray[kRampPos] * audio_frame->data_[i]); |
| 57 } | 57 } |
| 58 memset(&audio_frame->data_[kRampSize], 0, | 58 memset(&audio_frame->data_[kRampSize], 0, |
| 59 (audio_frame->samples_per_channel_ - kRampSize) * | 59 (audio_frame->samples_per_channel_ - kRampSize) * |
| 60 sizeof(audio_frame->data_[0])); | 60 sizeof(audio_frame->data_[0])); |
| 61 } | 61 } |
| 62 } // namespace webrtc | 62 } // namespace webrtc |
| OLD | NEW |