Home | History | Annotate | Download | only in source
      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 
     14 #include "typedefs.h"
     15 
     16 
     17 namespace webrtc {
     18 
     19 struct AudioChannel;
     20 struct SplitAudioChannel;
     21 class AudioFrame;
     22 
     23 class AudioBuffer {
     24  public:
     25   AudioBuffer(WebRtc_Word32 max_num_channels, WebRtc_Word32 samples_per_channel);
     26   virtual ~AudioBuffer();
     27 
     28   WebRtc_Word32 num_channels() const;
     29   WebRtc_Word32 samples_per_channel() const;
     30   WebRtc_Word32 samples_per_split_channel() const;
     31 
     32   WebRtc_Word16* data(WebRtc_Word32 channel) const;
     33   WebRtc_Word16* low_pass_split_data(WebRtc_Word32 channel) const;
     34   WebRtc_Word16* high_pass_split_data(WebRtc_Word32 channel) const;
     35   WebRtc_Word16* mixed_low_pass_data(WebRtc_Word32 channel) const;
     36   WebRtc_Word16* low_pass_reference(WebRtc_Word32 channel) const;
     37 
     38   WebRtc_Word32* analysis_filter_state1(WebRtc_Word32 channel) const;
     39   WebRtc_Word32* analysis_filter_state2(WebRtc_Word32 channel) const;
     40   WebRtc_Word32* synthesis_filter_state1(WebRtc_Word32 channel) const;
     41   WebRtc_Word32* synthesis_filter_state2(WebRtc_Word32 channel) const;
     42 
     43   void DeinterleaveFrom(AudioFrame* audioFrame);
     44   void InterleaveTo(AudioFrame* audioFrame) const;
     45   void Mix(WebRtc_Word32 num_mixed_channels);
     46   void CopyAndMixLowPass(WebRtc_Word32 num_mixed_channels);
     47   void CopyLowPassToReference();
     48 
     49  private:
     50   const WebRtc_Word32 max_num_channels_;
     51   WebRtc_Word32 num_channels_;
     52   WebRtc_Word32 num_mixed_channels_;
     53   WebRtc_Word32 num_mixed_low_pass_channels_;
     54   const WebRtc_Word32 samples_per_channel_;
     55   WebRtc_Word32 samples_per_split_channel_;
     56   bool reference_copied_;
     57 
     58   WebRtc_Word16* data_;
     59   // TODO(ajm): Prefer to make these vectors if permitted...
     60   AudioChannel* channels_;
     61   SplitAudioChannel* split_channels_;
     62   // TODO(ajm): improve this, we don't need the full 32 kHz space here.
     63   AudioChannel* mixed_low_pass_channels_;
     64   AudioChannel* low_pass_reference_channels_;
     65 };
     66 }  // namespace webrtc
     67 
     68 #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_
     69