| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_AUDIO_AUDIO_UTIL_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_UTIL_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_UTIL_H_ | 6 #define MEDIA_AUDIO_AUDIO_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| 12 // For all audio functions 3 audio formats are supported: |
| 13 // 8 bits unsigned 0 to 255. |
| 14 // 16 bit signed (little endian). |
| 15 // 32 bit signed (little endian) |
| 16 |
| 12 // AdjustVolume() does a software volume adjustment of a sample buffer. | 17 // AdjustVolume() does a software volume adjustment of a sample buffer. |
| 13 // The samples are multiplied by the volume, which should range from | 18 // The samples are multiplied by the volume, which should range from |
| 14 // 0.0 (mute) to 1.0 (full volume). | 19 // 0.0 (mute) to 1.0 (full volume). |
| 15 // Using software allows each audio and video to have its own volume without | 20 // Using software allows each audio and video to have its own volume without |
| 16 // affecting the master volume. | 21 // affecting the master volume. |
| 17 // In the future the function may be used to adjust the sample format to | 22 // In the future the function may be used to adjust the sample format to |
| 18 // simplify hardware requirements and to support a wider variety of input | 23 // simplify hardware requirements and to support a wider variety of input |
| 19 // formats. | 24 // formats. |
| 20 // The buffer is modified in-place to avoid memory management, as this | 25 // The buffer is modified in-place to avoid memory management, as this |
| 21 // function may be called in performance critical code. | 26 // function may be called in performance critical code. |
| 22 bool AdjustVolume(void* buf, | 27 bool AdjustVolume(void* buf, |
| 23 size_t buflen, | 28 size_t buflen, |
| 24 int channels, | 29 int channels, |
| 25 int bytes_per_sample, | 30 int bytes_per_sample, |
| 26 float volume); | 31 float volume); |
| 27 | 32 |
| 33 // FoldChannels() does a software multichannel folding down to stereo. |
| 34 // Channel order is assumed to be 5.1 Dolby standard which is |
| 35 // front left, front right, center, surround left, surround right. |
| 36 // The subwoofer is ignored. |
| 37 // 6.1 adds a rear center speaker, and 7.1 has 2 rear speakers. These |
| 38 // channels are rare and ignored. |
| 39 // After summing the channels, volume is adjusted and the samples are |
| 40 // clipped to the maximum value. |
| 41 // Volume should normally range from 0.0 (mute) to 1.0 (full volume), but |
| 42 // since clamping is performed a value of more than 1 is allowed to increase |
| 43 // volume. |
| 44 // The buffer is modified in-place to avoid memory management, as this |
| 45 // function may be called in performance critical code. |
| 46 bool FoldChannels(void* buf, |
| 47 size_t buflen, |
| 48 int channels, |
| 49 int bytes_per_sample, |
| 50 float volume); |
| 51 |
| 28 } // namespace media | 52 } // namespace media |
| 29 | 53 |
| 30 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ | 54 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ |
| OLD | NEW |