| 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_DSP_OCCLUSION_CALCULATOR_H_ |
| 18 | #define RESONANCE_AUDIO_DSP_OCCLUSION_CALCULATOR_H_ |
| 19 | |
| 20 | #include "base/spherical_angle.h" |
| 21 | |
| 22 | namespace vraudio { |
| 23 | |
| 24 | // Calculates directivity gain value for supplied source and listener |
| 25 | // parameters. |
| 26 | // |
| 27 | // @param alpha Balance between dipole pattern and omnidirectional pattern for |
| 28 | // source emission. By varying this value, differing directivity patterns |
| 29 | // can be formed. Value in range [0, 1]. 2D visualization for several |
| 30 | // values: http://goo.gl/GhKvoc. |
| 31 | // @param order Order of directivity function. Higher values will result in |
| 32 | // increased directivity. Value in range [1, +inf]. 2D visualization for |
| 33 | // several orders: |
| 34 | // http://goo.gl/sNrm1a. |
| 35 | // @param spherical_angle Spherical angle of the listener relative to the |
| 36 | // audio source which is being shaped. |
| 37 | // @return Gain value in range [0, 1]. |
| 38 | float CalculateDirectivity(float alpha, float order, |
| 39 | const SphericalAngle& spherical_angle); |
| 40 | |
| 41 | // This function calculates a |MonoPoleFilter| coefficient based upon the |
| 42 | // directivity and occlusion values. The coefficient calculation was designed |
| 43 | // via empirical methods. |
| 44 | // |
| 45 | // @param directivity Gain value calculated based upon the directivity. |
| 46 | // @param occlusion_intensity Gain value calculated based upon the degree of |
| 47 | // occlusion. |
| 48 | // @return Filter coefficient for a mono pole low pass filter. |
| 49 | float CalculateOcclusionFilterCoefficient(float directivity, |
| 50 | float occlusion_intensity); |
| 51 | |
| 52 | } // namespace vraudio |
| 53 | |
| 54 | #endif // RESONANCE_AUDIO_DSP_OCCLUSION_CALCULATOR_H_ |
| 55 | |