aboutsummaryrefslogtreecommitdiff
path: root/src/modules/audio_processing/main/source/audio_buffer.h
blob: 15f850b67b36a54de7bef8ca5bc093120d6827e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_

#include "typedefs.h"


namespace webrtc {

struct AudioChannel;
struct SplitAudioChannel;
class AudioFrame;

class AudioBuffer {
 public:
  AudioBuffer(WebRtc_Word32 max_num_channels, WebRtc_Word32 samples_per_channel);
  virtual ~AudioBuffer();

  WebRtc_Word32 num_channels() const;
  WebRtc_Word32 samples_per_channel() const;
  WebRtc_Word32 samples_per_split_channel() const;

  WebRtc_Word16* data(WebRtc_Word32 channel) const;
  WebRtc_Word16* low_pass_split_data(WebRtc_Word32 channel) const;
  WebRtc_Word16* high_pass_split_data(WebRtc_Word32 channel) const;
  WebRtc_Word16* mixed_low_pass_data(WebRtc_Word32 channel) const;
  WebRtc_Word16* low_pass_reference(WebRtc_Word32 channel) const;

  WebRtc_Word32* analysis_filter_state1(WebRtc_Word32 channel) const;
  WebRtc_Word32* analysis_filter_state2(WebRtc_Word32 channel) const;
  WebRtc_Word32* synthesis_filter_state1(WebRtc_Word32 channel) const;
  WebRtc_Word32* synthesis_filter_state2(WebRtc_Word32 channel) const;

  void DeinterleaveFrom(AudioFrame* audioFrame);
  void InterleaveTo(AudioFrame* audioFrame) const;
  void Mix(WebRtc_Word32 num_mixed_channels);
  void CopyAndMixLowPass(WebRtc_Word32 num_mixed_channels);
  void CopyLowPassToReference();

 private:
  const WebRtc_Word32 max_num_channels_;
  WebRtc_Word32 num_channels_;
  WebRtc_Word32 num_mixed_channels_;
  WebRtc_Word32 num_mixed_low_pass_channels_;
  const WebRtc_Word32 samples_per_channel_;
  WebRtc_Word32 samples_per_split_channel_;
  bool reference_copied_;

  WebRtc_Word16* data_;
  // TODO(ajm): Prefer to make these vectors if permitted...
  AudioChannel* channels_;
  SplitAudioChannel* split_channels_;
  // TODO(ajm): improve this, we don't need the full 32 kHz space here.
  AudioChannel* mixed_low_pass_channels_;
  AudioChannel* low_pass_reference_channels_;
};
}  // namespace webrtc

#endif  // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_