Wayverb
pressure_intensity.h
1 #pragma once
2 
3 #include <cmath>
4 
5 namespace wayverb {
6 namespace core {
7 
8 template <typename T, typename U>
9 inline auto pressure_to_intensity(T pressure, U Z) {
10  using std::copysign;
11  return copysign(pressure * pressure / Z, pressure);
12 }
13 
14 template <typename T, typename U>
15 inline auto intensity_to_pressure(T intensity, U Z) {
16  using std::copysign;
17  using std::sqrt;
18  using std::abs;
19  return copysign(sqrt(abs(intensity * Z)), intensity);
20 }
21 
22 double intensity_for_distance(double distance);
23 double pressure_for_distance(double distance, double acoustic_impedance);
24 
25 } // namespace core
26 } // namespace wayverb
Definition: traits.cpp:2
Definition: capsule_base.h:9