1/*
2Copyright 2018 Google Inc. All Rights Reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS-IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef RESONANCE_AUDIO_DSP_MIXER_H_
18#define RESONANCE_AUDIO_DSP_MIXER_H_
19
20#include <memory>
21
22#include "base/audio_buffer.h"
23
24namespace vraudio {
25
26// Accepts multiple input buffers and outputs a downmix to a single output
27// buffer. All input buffers must have the same number of frames per buffer, the
28// output will have the target number of channels regardless of the input number
29// of channels.
30class Mixer {
31 public:
32 // Constructor.
33 //
34 // @param target_num_channels Target number of channels in accumulator buffer.
35 // @param frames_per_buffer Number of frames in accumulator buffer.
36 Mixer(size_t target_num_channels, size_t frames_per_buffer);
37
38 // Adds an input buffer to the mixer, updates the output buffer accordingly.
39 //
40 // @param input Input buffer to be added.
41 void AddInput(const AudioBuffer& input);
42
43 // Returns a pointer to the accumulator.
44 //
45 // @return Pointer to the processed (mixed) output buffer, or nullptr if no
46 // input has been added to the accumulator.
47 const AudioBuffer* GetOutput() const;
48
49 // Resets the state of the accumulator.
50 void Reset();
51
52 private:
53 // Output buffer (accumulator).
54 AudioBuffer output_;
55
56 // Denotes whether the accumulator has processed any inputs or not.
57 bool is_empty_;
58};
59
60} // namespace vraudio
61
62#endif // RESONANCE_AUDIO_DSP_MIXER_H_
63

source code of qtmultimedia/src/3rdparty/resonance-audio/resonance_audio/dsp/mixer.h