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_NODE_H_ |
18 | #define RESONANCE_AUDIO_GRAPH_GAIN_NODE_H_ |
19 | |
20 | #include <memory> |
21 | #include <vector> |
22 | |
23 | #include "base/audio_buffer.h" |
24 | #include "base/constants_and_types.h" |
25 | #include "base/source_parameters.h" |
26 | #include "dsp/gain_processor.h" |
27 | #include "graph/system_settings.h" |
28 | #include "node/processing_node.h" |
29 | |
30 | namespace vraudio { |
31 | |
32 | // Node that calculates and applies a gain value to each channel of an input |
33 | // buffer based upon the given |GainCalculator|. |
34 | class GainNode : public ProcessingNode { |
35 | public: |
36 | // Constructs |GainNode| with given gain attenuation method. |
37 | // |
38 | // @param source_id Output buffer source id. |
39 | // @param num_channels Number of channels in the input buffer. |
40 | // @param attenuation_type Gain attenuation type to be used. |
41 | // @param system_settings Global system settings. |
42 | GainNode(SourceId source_id, size_t num_channels, |
43 | const AttenuationType& attenuation_type, |
44 | const SystemSettings& system_settings); |
45 | |
46 | protected: |
47 | // Implements ProcessingNode. |
48 | const AudioBuffer* AudioProcess(const NodeInput& input) override; |
49 | |
50 | private: |
51 | // Number of channels of the audio buffer. |
52 | const size_t num_channels_; |
53 | |
54 | // Gain attenuation type. |
55 | const AttenuationType attenuation_type_; |
56 | |
57 | // Gain processors per each channel. |
58 | std::vector<GainProcessor> gain_processors_; |
59 | |
60 | // Global system settings. |
61 | const SystemSettings& system_settings_; |
62 | |
63 | // Output buffer. |
64 | AudioBuffer output_buffer_; |
65 | }; |
66 | |
67 | } // namespace vraudio |
68 | |
69 | #endif // RESONANCE_AUDIO_GRAPH_GAIN_NODE_H_ |
70 | |