Commit 462e4ad8 authored by henryjandrew's avatar henryjandrew

Added updated calculation for maximum needed IR length and commented out...

Added updated calculation for maximum needed IR length and commented out source directivity in-development code
parent 09cd7302
......@@ -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<const CVADirectivityDAFFHRIR*>(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
*/
//======================================================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment