niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_ |
| 13 | |
pbos@webrtc.org | 7fad4b8 | 2013-05-28 08:11:59 +0000 | [diff] [blame] | 14 | #include "webrtc/modules/interface/module_common_types.h" |
| 15 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
| 16 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | namespace webrtc { |
| 19 | |
| 20 | struct AudioChannel; |
| 21 | struct SplitAudioChannel; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
| 23 | class AudioBuffer { |
| 24 | public: |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 25 | AudioBuffer(int max_num_channels, int samples_per_channel); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | virtual ~AudioBuffer(); |
| 27 | |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 28 | int num_channels() const; |
| 29 | int samples_per_channel() const; |
| 30 | int samples_per_split_channel() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 32 | int16_t* data(int channel) const; |
| 33 | int16_t* low_pass_split_data(int channel) const; |
| 34 | int16_t* high_pass_split_data(int channel) const; |
| 35 | int16_t* mixed_data(int channel) const; |
| 36 | int16_t* mixed_low_pass_data(int channel) const; |
| 37 | int16_t* low_pass_reference(int channel) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 39 | int32_t* analysis_filter_state1(int channel) const; |
| 40 | int32_t* analysis_filter_state2(int channel) const; |
| 41 | int32_t* synthesis_filter_state1(int channel) const; |
| 42 | int32_t* synthesis_filter_state2(int channel) const; |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 43 | |
| 44 | void set_activity(AudioFrame::VADActivity activity); |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 45 | AudioFrame::VADActivity activity() const; |
| 46 | |
| 47 | bool is_muted() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
| 49 | void DeinterleaveFrom(AudioFrame* audioFrame); |
| 50 | void InterleaveTo(AudioFrame* audioFrame) const; |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 51 | // If |data_changed| is false, only the non-audio data members will be copied |
| 52 | // to |frame|. |
| 53 | void InterleaveTo(AudioFrame* frame, bool data_changed) const; |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 54 | void Mix(int num_mixed_channels); |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 55 | void CopyAndMix(int num_mixed_channels); |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 56 | void CopyAndMixLowPass(int num_mixed_channels); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | void CopyLowPassToReference(); |
| 58 | |
| 59 | private: |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 60 | const int max_num_channels_; |
| 61 | int num_channels_; |
| 62 | int num_mixed_channels_; |
| 63 | int num_mixed_low_pass_channels_; |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 64 | // Whether the original data was replaced with mixed data. |
| 65 | bool data_was_mixed_; |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 66 | const int samples_per_channel_; |
| 67 | int samples_per_split_channel_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | bool reference_copied_; |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 69 | AudioFrame::VADActivity activity_; |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 70 | bool is_muted_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 72 | int16_t* data_; |
| 73 | scoped_array<AudioChannel> channels_; |
| 74 | scoped_array<SplitAudioChannel> split_channels_; |
| 75 | scoped_array<AudioChannel> mixed_channels_; |
andrew@webrtc.org | ed083d4 | 2011-09-19 15:28:51 +0000 | [diff] [blame] | 76 | // TODO(andrew): improve this, we don't need the full 32 kHz space here. |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 77 | scoped_array<AudioChannel> mixed_low_pass_channels_; |
| 78 | scoped_array<AudioChannel> low_pass_reference_channels_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | }; |
| 80 | } // namespace webrtc |
| 81 | |
| 82 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_ |