38static const double p11[19] = { 12.97, 13.19, 12.13, 11.19, 9.91, 8.328, 6.493, 4.455, 2.274, 0.018, -2.24, -4.43, -6.49, -8.34, -9.93, -11.3, -12.2, -12.8, -13.0 };
39static const double p21[19] = { -9.69, 234.2, -11.2, -9.03, -7.87, -7.42, -7.31, -7.28, -7.29, -7.48, -8.04, -9.23, -11.6, -17.4, -48.4, 9.149, 1.905, -0.75, -1.32 };
40static const double q11[19] = { -1.14, 18.48, -1.25, -1.02, -0.83, -0.67, -0.5, -0.32, -0.11, -0.13, 0.395, 0.699, 1.084, 1.757, 4.764, -0.64, 0.109, 0.386, 0.45 };
41static const double q21[19] = { 0.219, -8.5, 0.346, 0.336, 0.379, 0.421, 0.423, 0.382, 0.314, 0.24, 0.177, 0.132, 0.113, 0.142, 0.462, -0.14, -0.08, -0.06, -0.05 };
42static const double p12[19] = { -4.39, -4.31, -4.18, -4.01, -3.87, -4.1, -3.87, -5.02, -6.72, -8.69, -11.2, -12.1, -11.1, -11.1, -9.72, -8.42, -7.44, -6.78, -6.58 };
43static const double p22[19] = { 2.123, -2.78, 4.224, 3.039, -0.57, -34.7, 3.271, 0.023, -8.96, -58.4, 11.47, 8.716, 21.8, 1.91, -0.04, -0.66, 0.395, 2.662, 3.387 };
44static const double q12[19] = { -0.55, 0.59, -1.01, -0.56, 0.665, 11.39, -1.57, -0.87, 0.37, 5.446, -1.13, -0.63, -2.01, 0.15, 0.243, 0.147, -0.18, -0.67, -0.84 };
45static const double q22[19] = { -0.06, -0.17, -0.02, -0.32, -1.13, -8.3, 0.637, 0.325, -0.08, -1.19, 0.103, -0.12, 0.098, -0.4, -0.41, -0.34, -0.18, 0.05, 0.131 };
46static const double p13[19] = { 0.457, 0.455, -0.87, 0.465, 0.494, 0.549, 0.663, 0.691, 3.507, -27.4, 6.371, 7.032, 7.092, 7.463, 7.453, 8.101, 8.702, 8.925, 9.317 };
47static const double p23[19] = { -0.67, 0.142, 3404., -0.91, -0.67, -1.21, -1.76, 4.655, 55.09, 10336., 1.735, 40.88, 23.86, 102.8, -6.14, -18.1, -9.05, -9.03, -6.89 };
48static const double p33[19] = { 0.174, -0.11, -1699., 0.437, 0.658, 2.02, 6.815, 0.614, 589.3, 16818., -9.39, -44.1, -23.6, -92.3, -1.81, 10.54, 0.532, 0.285, -2.08 };
49static const double q13[19] = { -1.75, -0.01, 7354., -2.18, -1.2, -1.59, -1.23, -0.89, 29.23, 1945., -0.06, 5.635, 3.308, 13.88, -0.88, -2.23, -0.96, -0.9, -0.57 };
50static const double q23[19] = { 0.699, -0.35, -5350., 1.188, 0.256, 0.816, 1.166, 0.76, 59.51, 1707., -1.12, -6.18, -3.39, -12.7, -0.19, 1.295, -0.02, -0.08, -0.4 };
51static const int numAz_table =
sizeof(q23) /
sizeof(q23[0]);
55static const float headDim =
SAF_PI * (0.0875f / 0.09096f);
56static const float sosDiv2PiA = 343.0f / (2.0f *
SAF_PI * 0.09096f);
66 return a + (b-a) * ifac;
75 return powf(10.f, dB / 20.f);
91 double rho = (double)rhoIn;
92 double rhoSq = rho * rho;
95 *g0 = (float)((
p11[i] * rho + p21[i]) / (rhoSq + q11[i] * rho + q21[i]));
96 *gInf = (float)((p12[i] * rho + p22[i]) / (rhoSq + q12[i] * rho + q22[i]));
97 fc_tmp = (float)((p13[i] * rhoSq + p23[i] * rho + p33[i]) / (rhoSq + q13[i] * rho + q23[i]));
100 *fc = fc_tmp * sosDiv2PiA;
117 int theta_idx_lower, theta_idx_upper;
118 float ifac, thetaDiv10;
120 float gInf_1, gInf_2;
127 thetaDiv10 = theta / 10.f;
128 theta_idx_lower = (int)thetaDiv10;
129 theta_idx_upper = theta_idx_lower + 1;
130 if(theta_idx_upper >= numAz_table) {
131 theta_idx_upper = numAz_table - 1;
132 theta_idx_lower = theta_idx_upper - 1;
139 ifac = thetaDiv10 - theta_idx_lower;
161 float v0, g0_mag, tanF, v0tanF;
166 tanF = tanf((headDim / fs) * fc);
168 a_c = (v0tanF - 1.f) / (v0tanF + 1.f);
170 v = (v0 - 1.f) * 0.5f;
172 *b0 = g0_mag * (v - va_c + 1.f);
173 *b1 = g0_mag * (va_c - v + a_c);
186 float iG0, iGInf, iFc;
199 float az_rad, el_rad, alpha_ipsi, beta_ipsi, alpha_ipsi_deg, beta_ipsi_deg;
200 float sinaz, sinel, cosaz, cosel;
204 sinaz = sinf(az_rad);
205 sinel = sinf(el_rad);
206 cosaz = cosf(az_rad);
207 cosel = cosf(el_rad);
208 alpha_ipsi =
SAF_PI/2.f - acosf(sinaz * cosel);
209 beta_ipsi = asinf(sinel / sqrtf(powf(sinel,2.f) + (powf(cosaz,2.f) * powf(cosel,2.f))));
212 if(beta_ipsi >
SAF_PI/2.f) {
213 alpha_ipsi =
SAF_PI - alpha_ipsi;
214 beta_ipsi =
SAF_PI - beta_ipsi;
218 alpha_ipsi = fabsf(
SAF_PI/2.f - alpha_ipsi);
220 alpha_ipsi = 2*
SAF_PI - alpha_ipsi;
222 alphaLR[0] = alpha_ipsi_deg =
RAD2DEG(alpha_ipsi);
223 alphaLR[1] = 180.f - alpha_ipsi_deg;
225 if (betaLR != NULL) {
226 betaLR[0] = beta_ipsi_deg =
RAD2DEG(beta_ipsi);
227 betaLR[1] = 180.f - beta_ipsi_deg;
void doaToIpsiInteraural(float azimuth, float elevation, float *alphaLR, float *betaLR)
Convert a frontal azimuth/elevation to a modified Interaural-Polar coordinate.
#define SAF_CLAMP(a, min, max)
Ensures value "a" is clamped between the "min" and "max" values.
#define SAF_PI
pi constant (single precision)
#define DEG2RAD(x)
Converts degrees to radians.
#define SAF_MAX(a, b)
Returns the maximum of the two values.
void interpDVFShelfParams(float theta, float rho, float *iG0, float *iGInf, float *iFc)
Calculate the shelving filter parameters for the Distance Variation Function filter from the source (...
void dvfShelfCoeffs(float g0, float gInf, float fc, float fs, float *b0, float *b1, float *a1)
Calculate the DVF filter coefficients from shelving filter parameters.
void calcDVFCoeffs(float alpha, float rho, float fs, float *b, float *a)
Calculate the Distance Variation Function (DVF) filter coefficients, as described in [1].
void calcDVFShelfParams(int i, float rhoIn, float *g0, float *gInf, float *fc)
Calculate the high shelf gains and cutoff parameters, given a azimuth index i and distance rho.
#define RAD2DEG(x)
Converts radians to degrees
static float interpolate_lin(float a, float b, float ifac)
Linear interpolation between two values.
static const double p11[19]
Table 1: Coefficients for Eqs.
static float db2mag(float dB)
Covert decibels to a magnitude.
Distance variation function filter coefficient data [1].
A collection of IIR/FIR filter and filterbank designs.