diff options
Diffstat (limited to 'media/audio/audio_util.h')
-rw-r--r-- | media/audio/audio_util.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/media/audio/audio_util.h b/media/audio/audio_util.h index 14fe169..edfe7ab 100644 --- a/media/audio/audio_util.h +++ b/media/audio/audio_util.h @@ -9,6 +9,11 @@ namespace media { +// For all audio functions 3 audio formats are supported: +// 8 bits unsigned 0 to 255. +// 16 bit signed (little endian). +// 32 bit signed (little endian) + // AdjustVolume() does a software volume adjustment of a sample buffer. // The samples are multiplied by the volume, which should range from // 0.0 (mute) to 1.0 (full volume). @@ -25,6 +30,25 @@ bool AdjustVolume(void* buf, int bytes_per_sample, float volume); +// FoldChannels() does a software multichannel folding down to stereo. +// Channel order is assumed to be 5.1 Dolby standard which is +// front left, front right, center, surround left, surround right. +// The subwoofer is ignored. +// 6.1 adds a rear center speaker, and 7.1 has 2 rear speakers. These +// channels are rare and ignored. +// After summing the channels, volume is adjusted and the samples are +// clipped to the maximum value. +// Volume should normally range from 0.0 (mute) to 1.0 (full volume), but +// since clamping is performed a value of more than 1 is allowed to increase +// volume. +// The buffer is modified in-place to avoid memory management, as this +// function may be called in performance critical code. +bool FoldChannels(void* buf, + size_t buflen, + int channels, + int bytes_per_sample, + float volume); + } // namespace media #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ |