void HrtfData::sample_direction(angle_t elevation, angle_t azimuth, distance_t distance, uint32_t sample, float& value_left, float& delay_left, float& value_right, float& delay_right) const { _ASSERT(elevation >= -angle_t(pi * 0.5)); _ASSERT(elevation <= angle_t(pi * 0.5)); _ASSERT(azimuth >= -angle_t(2.0 * pi)); _ASSERT(azimuth <= angle_t(2.0 * pi)); sample_direction(elevation, azimuth, distance, sample, value_left, delay_left); sample_direction(elevation, -azimuth, distance, sample, value_right, delay_right); }
void HrtfData::get_direction_data(angle_t elevation, angle_t azimuth, distance_t distance, DirectionData& ref_data_left, DirectionData& ref_data_right) const { _ASSERT(elevation >= -angle_t(pi * 0.5)); _ASSERT(elevation <= angle_t(pi * 0.5)); _ASSERT(azimuth >= -angle_t(2.0 * pi)); _ASSERT(azimuth <= angle_t(2.0 * pi)); get_direction_data(elevation, azimuth, distance, ref_data_left); get_direction_data(elevation, -azimuth, distance, ref_data_right); }
void RenderViewport::InitTextureMapping() { int i; // Calc focallength so FieldOfView angles cover viewwidth. FocalLengthX = CenterX / viewwindow.FocalTangent; FocalLengthY = FocalLengthX * YaspectMul; // This is 1/FocalTangent before the widescreen extension of FOV. viewingrangerecip = FLOAT2FIXED(1. / tan(viewpoint.FieldOfView.Radians() / 2)); // Now generate xtoviewangle for sky texture mapping. // [RH] Do not generate viewangletox, because texture mapping is no // longer done with trig, so it's not needed. const double slopestep = viewwindow.FocalTangent / viewwindow.centerx; double slope; for (i = viewwindow.centerx, slope = 0; i <= viewwidth; i++, slope += slopestep) { xtoviewangle[i] = angle_t((2 * M_PI - atan(slope)) * (ANGLE_180 / M_PI)); } for (i = 0; i < viewwindow.centerx; i++) { xtoviewangle[i] = 0 - xtoviewangle[viewwidth - i - 1]; } }
ExpVal EvalExpression(AActor *self) { double v = (*ArgList)[0]->EvalExpression(self).GetFloat(); ExpVal ret; ret.Type = VAL_Float; // shall we use the CRT's sin and cos functions? angle_t angle = angle_t(v * ANGLE_90/90.); if (Name == NAME_Sin) ret.Float = FIXED2DBL (finesine[angle>>ANGLETOFINESHIFT]); else ret.Float = FIXED2DBL (finecosine[angle>>ANGLETOFINESHIFT]);
void HrtfData::get_direction_data(angle_t elevation, angle_t azimuth, distance_t distance, DirectionData& ref_data) const { _ASSERT(elevation >= -angle_t(pi * 0.5)); _ASSERT(elevation <= angle_t(pi * 0.5)); _ASSERT(azimuth >= -angle_t(2.0 * pi)); _ASSERT(azimuth <= angle_t(2.0 * pi)); const float azimuth_mod = std::fmod(azimuth + angle_t(pi * 2.0), angle_t(pi * 2.0)); const angle_t elevation_scaled = (elevation + angle_t(pi * 0.5)) * (m_elevations.size() - 1) / angle_t(pi); const size_t elevation_index0 = static_cast<size_t>(elevation_scaled); const size_t elevation_index1 = std::min(elevation_index0 + 1, m_elevations.size() - 1); const float elevation_fractional_part = elevation_scaled - std::floor(elevation_scaled); const angle_t azimuth_scaled0 = azimuth_mod * m_elevations[elevation_index0].azimuths.size() / angle_t(2 * pi); const size_t azimuth_index00 = static_cast<size_t>(azimuth_scaled0) % m_elevations[elevation_index0].azimuths.size(); const size_t azimuth_index01 = static_cast<size_t>(azimuth_scaled0 + 1) % m_elevations[elevation_index0].azimuths.size(); const float azimuth_fractional_part0 = azimuth_scaled0 - std::floor(azimuth_scaled0); const angle_t azimuth_scaled1 = azimuth_mod * m_elevations[elevation_index1].azimuths.size() / angle_t(2 * pi); const size_t azimuth_index10 = static_cast<size_t>(azimuth_scaled1) % m_elevations[elevation_index1].azimuths.size(); const size_t azimuth_index11 = static_cast<size_t>(azimuth_scaled1 + 1) % m_elevations[elevation_index1].azimuths.size(); const float azimuth_fractional_part1 = azimuth_scaled1 - std::floor(azimuth_scaled1); const float blend_factor_00 = (1.0f - elevation_fractional_part) * (1.0f - azimuth_fractional_part0); const float blend_factor_01 = (1.0f - elevation_fractional_part) * azimuth_fractional_part0; const float blend_factor_10 = elevation_fractional_part * (1.0f - azimuth_fractional_part1); const float blend_factor_11 = elevation_fractional_part * azimuth_fractional_part1; ref_data.delay = m_elevations[elevation_index0].azimuths[azimuth_index00].delay * blend_factor_00 + m_elevations[elevation_index0].azimuths[azimuth_index01].delay * blend_factor_01 + m_elevations[elevation_index1].azimuths[azimuth_index10].delay * blend_factor_10 + m_elevations[elevation_index1].azimuths[azimuth_index11].delay * blend_factor_11; if (ref_data.impulse_response.size() < m_response_length) ref_data.impulse_response.resize(m_response_length); for (size_t i = 0; i < m_response_length; i++) { ref_data.impulse_response[i] = m_elevations[elevation_index0].azimuths[azimuth_index00].impulse_response[i] * blend_factor_00 + m_elevations[elevation_index0].azimuths[azimuth_index01].impulse_response[i] * blend_factor_01 + m_elevations[elevation_index1].azimuths[azimuth_index10].impulse_response[i] * blend_factor_10 + m_elevations[elevation_index1].azimuths[azimuth_index11].impulse_response[i] * blend_factor_11; } }
void HrtfData::sample_direction(angle_t elevation, angle_t azimuth, distance_t distance, uint32_t sample, float& value, float& delay) const { _ASSERT(elevation >= -angle_t(pi * 0.5)); _ASSERT(elevation <= angle_t(pi * 0.5)); _ASSERT(azimuth >= -angle_t(2.0 * pi)); _ASSERT(azimuth <= angle_t(2.0 * pi)); const float azimuth_mod = std::fmod(azimuth + angle_t(pi * 2.0), angle_t(pi * 2.0)); const angle_t elevation_scaled = (elevation + angle_t(pi * 0.5)) * (m_elevations.size() - 1) / angle_t(pi); const size_t elevation_index0 = static_cast<size_t>(elevation_scaled); const size_t elevation_index1 = std::min(elevation_index0 + 1, m_elevations.size() - 1); const float elevation_fractional_part = elevation_scaled - std::floor(elevation_scaled); const angle_t azimuth_scaled0 = azimuth_mod * m_elevations[elevation_index0].azimuths.size() / angle_t(pi * 2.0); const size_t azimuth_index00 = static_cast<size_t>(azimuth_scaled0) % m_elevations[elevation_index0].azimuths.size(); const size_t azimuth_index01 = static_cast<size_t>(azimuth_scaled0 + 1) % m_elevations[elevation_index0].azimuths.size(); const float azimuth_fractional_part0 = azimuth_scaled0 - std::floor(azimuth_scaled0); const angle_t azimuth_scaled1 = azimuth_mod * m_elevations[elevation_index1].azimuths.size() / angle_t(pi * 2.0); const size_t azimuth_index10 = static_cast<size_t>(azimuth_scaled1) % m_elevations[elevation_index1].azimuths.size(); const size_t azimuth_index11 = static_cast<size_t>(azimuth_scaled1 + 1) % m_elevations[elevation_index1].azimuths.size(); const float azimuth_fractional_part1 = azimuth_scaled1 - std::floor(azimuth_scaled1); const float blend_factor_00 = (1.0f - elevation_fractional_part) * (1.0f - azimuth_fractional_part0); const float blend_factor_01 = (1.0f - elevation_fractional_part) * azimuth_fractional_part0; const float blend_factor_10 = elevation_fractional_part * (1.0f - azimuth_fractional_part1); const float blend_factor_11 = elevation_fractional_part * azimuth_fractional_part1; delay = m_elevations[elevation_index0].azimuths[azimuth_index00].delay * blend_factor_00 + m_elevations[elevation_index0].azimuths[azimuth_index01].delay * blend_factor_01 + m_elevations[elevation_index1].azimuths[azimuth_index10].delay * blend_factor_10 + m_elevations[elevation_index1].azimuths[azimuth_index11].delay * blend_factor_11; value = m_elevations[elevation_index0].azimuths[azimuth_index00].impulse_response[sample] * blend_factor_00 + m_elevations[elevation_index0].azimuths[azimuth_index01].impulse_response[sample] * blend_factor_01 + m_elevations[elevation_index1].azimuths[azimuth_index10].impulse_response[sample] * blend_factor_10 + m_elevations[elevation_index1].azimuths[azimuth_index11].impulse_response[sample] * blend_factor_11; }
angle_t UDMFParserBase::CheckAngle(const char *key) { return angle_t(CheckFloat(key) * ANGLE_90 / 90.); }