| 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_OCCLUSION_NODE_H_ | 
| 18 | #define RESONANCE_AUDIO_GRAPH_OCCLUSION_NODE_H_ | 
| 19 |  | 
| 20 | #include "base/audio_buffer.h" | 
| 21 | #include "dsp/mono_pole_filter.h" | 
| 22 | #include "graph/system_settings.h" | 
| 23 | #include "node/processing_node.h" | 
| 24 |  | 
| 25 | namespace vraudio { | 
| 26 |  | 
| 27 | // Node that accepts a single audio buffer as input and outputs the input buffer | 
| 28 | // with its cuttoff frequency scaled by listener/source directivity and | 
| 29 | // occlusion intensity. | 
| 30 | class OcclusionNode : public ProcessingNode { | 
| 31 |  public: | 
| 32 |   // Constructor. | 
| 33 |   // | 
| 34 |   // @param source_id Output buffer source id. | 
| 35 |   // @param system_settings Global system settings. | 
| 36 |   OcclusionNode(SourceId source_id, const SystemSettings& system_settings); | 
| 37 |  | 
| 38 |  protected: | 
| 39 |   // Implements ProcessingNode. | 
| 40 |   const AudioBuffer* AudioProcess(const NodeInput& input) override; | 
| 41 |  | 
| 42 |  private: | 
| 43 |   friend class OcclusionNodeTest; | 
| 44 |  | 
| 45 |   const SystemSettings& system_settings_; | 
| 46 |  | 
| 47 |   // Used to low-pass input audio when a source is occluded or self-occluded. | 
| 48 |   MonoPoleFilter low_pass_filter_; | 
| 49 |  | 
| 50 |   // Occlusion intensity value for the current input buffer. | 
| 51 |   float current_occlusion_; | 
| 52 |  | 
| 53 |   // Output buffer. | 
| 54 |   AudioBuffer output_buffer_; | 
| 55 | }; | 
| 56 |  | 
| 57 | }  // namespace vraudio | 
| 58 |  | 
| 59 | #endif  // RESONANCE_AUDIO_GRAPH_OCCLUSION_NODE_H_ | 
| 60 |  |