| 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_STEREO_MIXING_PANNER_NODE_H_ | 
| 18 | #define RESONANCE_AUDIO_GRAPH_STEREO_MIXING_PANNER_NODE_H_ | 
| 19 |  | 
| 20 | #include <vector> | 
| 21 |  | 
| 22 | #include "base/audio_buffer.h" | 
| 23 | #include "dsp/gain_mixer.h" | 
| 24 | #include "graph/system_settings.h" | 
| 25 | #include "node/processing_node.h" | 
| 26 |  | 
| 27 | namespace vraudio { | 
| 28 |  | 
| 29 | // Node that accepts single mono sound object buffer as input and pans into a | 
| 30 | // stereo panorama. | 
| 31 | class StereoMixingPannerNode : public ProcessingNode { | 
| 32 |  public: | 
| 33 |   // Initializes StereoMixingPannerNode class. | 
| 34 |   // | 
| 35 |   // @param system_settings Global system configuration. | 
| 36 |   explicit StereoMixingPannerNode(const SystemSettings& system_settings); | 
| 37 |  | 
| 38 |   // Node implementation. | 
| 39 |   bool CleanUp() final { | 
| 40 |     CallCleanUpOnInputNodes(); | 
| 41 |     // Prevent node from being disconnected when all sources are removed. | 
| 42 |     return false; | 
| 43 |   } | 
| 44 |  | 
| 45 |  protected: | 
| 46 |   // Implements ProcessingNode. | 
| 47 |   const AudioBuffer* AudioProcess(const NodeInput& input) override; | 
| 48 |  | 
| 49 |  private: | 
| 50 |   const SystemSettings& system_settings_; | 
| 51 |  | 
| 52 |   // |GainMixer| instance. | 
| 53 |   GainMixer gain_mixer_; | 
| 54 |  | 
| 55 |   // Panning coefficients to be applied the input. | 
| 56 |   std::vector<float> coefficients_; | 
| 57 | }; | 
| 58 |  | 
| 59 | }  // namespace vraudio | 
| 60 |  | 
| 61 | #endif  // RESONANCE_AUDIO_GRAPH_STEREO_MIXING_PANNER_NODE_H_ | 
| 62 |  |