11 #ifndef SAL_DIRECTIVITYFUNCTION_H
12 #define SAL_DIRECTIVITYFUNCTION_H
31 const mcl::Point& point,
32 const Int& wave_id = 0) noexcept {
34 AddPlaneWave(&input_sample, 1, point, wave_id, output_buffer);
53 virtual Sample GetDirectivity(
const mcl::Point& point) = 0;
65 const Int num_samples,
66 const mcl::Point& point,
68 Buffer& output_buffer) noexcept {
69 ASSERT(output_buffer.num_channels() >= 1);
70 ASSERT(num_samples <= output_buffer.num_samples());
72 mcl::MultiplyAdd(input_data,
73 GetDirectivity(point),
81 virtual Sample GetDirectivity(
const mcl::Point& point) = 0;
88 Microphone(position, mcl::Quaternion::Identity()),
92 virtual bool IsOmni() const noexcept {
return true; }
97 virtual Sample GetDirectivity(
const mcl::Point& ) {
108 Microphone(position, mcl::Quaternion::Identity()),
123 std::vector<Sample> coefficients) :
126 coefficients_(coefficients) {}
130 virtual Sample GetDirectivity(
const mcl::Point& point) {
131 Angle phi = AngleBetweenPoints(point,
132 mcl::Point(1.0, 0.0, 0.0));
134 const Int N = coefficients_.size();
135 Sample directivity(coefficients_[0]);
136 for (
Int i=1; i<N; ++i) { directivity += coefficients_[i]*pow(cos(phi),i); }
140 std::vector<Sample> coefficients_;
155 base_angle_(base_angle) {}
159 virtual Sample GetDirectivity(
const mcl::Point& point) {
160 Angle phi = AngleBetweenPoints(point, mcl::Point(1.0, 0.0, 0.0));
168 1.0/sqrt(1+pow(sin(phi-phi_l), 2.0)/pow(sin(phi_lp1-phi), 2.0));
169 }
else { directivity = 0.0; }