From 462e4ad8f4b7dd47a6027240eef742cf821cfe33 Mon Sep 17 00:00:00 2001 From: henryjandrew Date: Tue, 9 Apr 2019 18:18:48 +0200 Subject: [PATCH] Added updated calculation for maximum needed IR length and commented out source directivity in-development code --- .../VAPTImageSourceAudioRenderer.cpp | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Rendering/Prototyping/ImageSource/VAPTImageSourceAudioRenderer.cpp b/src/Rendering/Prototyping/ImageSource/VAPTImageSourceAudioRenderer.cpp index 271e128..c711d2c 100644 --- a/src/Rendering/Prototyping/ImageSource/VAPTImageSourceAudioRenderer.cpp +++ b/src/Rendering/Prototyping/ImageSource/VAPTImageSourceAudioRenderer.cpp @@ -308,12 +308,24 @@ void CVAPTImageSourceAudioRenderer::Reset() void CVAPTImageSourceAudioRenderer::SetIRFilterLength() { //called whenever the room dimensions or image source max order are changed to set a value for the IR filter length which will not be exceeded - float max_dimension = std::fmax(m_RoomLength, m_RoomWidth); //find maximum room dimension - max_dimension = std::fmax(max_dimension, m_RoomHeight); + //-----------------------------------------sort dimensions (bubble sort)-------------------------------------- + float first = m_RoomLength, second = m_RoomWidth, third = m_RoomHeight; + if (first > second) + std::swap(first, second); + if (second > third) + std::swap(second, third); + if (first > second) + std::swap(first, second); + int sampling_rate = (int)m_oParams.pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate; //get the sampling rate from the core config float c = m_oParams.pCore->GetHomogeneousMediumSoundSpeed(); //get speed of sound from within VA - int max_filter_length = ceil(sampling_rate * (m_MaxOrder + 1) * max_dimension / c) + m_HRIR_length; //calculate the max. filter length needed + float max_distance = 2 * sqrt(pow(third,2) + pow(second/2,2) + pow(third/2,2)); //max distance for a first order image source ray + int max_filter_length = ceil( (m_MaxOrder+1) * max_distance / c * sampling_rate ); m_iIRFilterLengthSamples = min(m_iIRFilterLengthSamples_ref, max_filter_length); //if the max. possible filter length is less than the value given in the config file, set to max filter length + + if(m_iIRFilterLengthSamples_ref != m_iIRFilterLengthSamples) //if different filter length to user setting is used + VA_WARN("PTImageSourceAudioRenderer", "Filter length shortened from user input to maximum needed with given room dimensions"); + } void CVAPTImageSourceAudioRenderer::UpdateFilter() @@ -412,11 +424,12 @@ void CVAPTImageSourceAudioRenderer::CalculateImageSourceImpulseResponse(ITASampl const CVADirectivityDAFFHRIR* pDAFFDirectivityListener = dynamic_cast(pListenerState->GetDirectivity()); //-------------------------------------------------------experimental source directivity--------------------------------------------------------------- + /* CVASoundSourceState* pSourceNew = (m_pNewSceneState ? m_pNewSceneState->GetSoundSourceState(source_ID) : nullptr); IVADirectivity *test; if (pSourceNew != nullptr) test = (IVADirectivity*)pSourceNew->GetDirectivityData(); - + */ //------------------------------------------------------------------------------- @@ -461,7 +474,7 @@ void CVAPTImageSourceAudioRenderer::CalculateImageSourceImpulseResponse(ITASampl //====================================================================================================== - + /* VAVec3 p_hat_dash, source_angle_polar; p_hat_dash.x = -p_hat.x * pow(-1, abs(l - u) + abs(l)); p_hat_dash.y = -p_hat.y * pow(-1, abs(m - v) + abs(m)); @@ -469,7 +482,7 @@ void CVAPTImageSourceAudioRenderer::CalculateImageSourceImpulseResponse(ITASampl CartVec2PolarVec(p_hat_dash, &source_angle_polar); //finds the angle from the ray leaving the source //get attenuation factor for this angle //scale amplitude - + */ //====================================================================================================== -- GitLab