1 | /* |
2 | Copyright 2018 Google Inc. All Rights Reserved. |
3 | |
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | you may not use this file except in compliance with the License. |
6 | You may obtain a copy of the License at |
7 | |
8 | http://www.apache.org/licenses/LICENSE-2.0 |
9 | |
10 | Unless required by applicable law or agreed to in writing, software |
11 | distributed under the License is distributed on an "AS-IS" BASIS, |
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | See the License for the specific language governing permissions and |
14 | limitations under the License. |
15 | */ |
16 | |
17 | #ifndef RESONANCE_AUDIO_GRAPH_GAIN_MIXER_NODE_H_ |
18 | #define RESONANCE_AUDIO_GRAPH_GAIN_MIXER_NODE_H_ |
19 | |
20 | #include "base/audio_buffer.h" |
21 | #include "base/source_parameters.h" |
22 | #include "dsp/gain_mixer.h" |
23 | #include "graph/system_settings.h" |
24 | #include "node/processing_node.h" |
25 | |
26 | namespace vraudio { |
27 | |
28 | // Node that accepts multiple input buffers, calculates and applies a gain |
29 | // value to each buffer based upon the given |AttenuationType| and then mixes |
30 | // the results together. |
31 | class GainMixerNode : public ProcessingNode { |
32 | public: |
33 | // Constructs |GainMixerNode| with given gain calculation method. |
34 | // |
35 | // @param attenuation_type Gain attenuation type to be used. |
36 | // @param system_settings Global system settings. |
37 | // @param num_channels Number of channels. |
38 | GainMixerNode(const AttenuationType& attenuation_type, |
39 | const SystemSettings& system_settings, size_t num_channels); |
40 | |
41 | // Mute the mixer node by skipping the audio processing and outputting nullptr |
42 | // buffers. |
43 | void SetMute(bool mute_enabled); |
44 | |
45 | // Node implementation. |
46 | bool CleanUp() final; |
47 | |
48 | protected: |
49 | // Implements ProcessingNode. |
50 | const AudioBuffer* AudioProcess(const NodeInput& input) override; |
51 | |
52 | private: |
53 | // Flag indicating the mute status. |
54 | bool mute_enabled_; |
55 | |
56 | // Gain attenuation type. |
57 | const AttenuationType attenuation_type_; |
58 | |
59 | // Gain mixer. |
60 | GainMixer gain_mixer_; |
61 | |
62 | // Global system settings. |
63 | const SystemSettings& system_settings_; |
64 | }; |
65 | |
66 | } // namespace vraudio |
67 | |
68 | #endif // RESONANCE_AUDIO_GRAPH_GAIN_MIXER_NODE_H_ |
69 | |