Commit f4c75a29 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Fixing reset bugs and adding verbose outputs during reset in mono and binaural...

Fixing reset bugs and adding verbose outputs during reset in mono and binaural FF renderer. ActiveListener still a problem, will have to move to versioned scene handling.
parent 941c5663
......@@ -11,21 +11,21 @@
// Mediator-Thread benutzen?
//#define USE_MEDIATOR_THREAD
CVAPortaudioBackend::CVAPortaudioBackend(CVAAudioDriverConfig* pConfig)
: m_pMediator(nullptr), m_pConfig(pConfig), m_bStreaming(false)
CVAPortaudioBackend::CVAPortaudioBackend( CVAAudioDriverConfig* pConfig )
: m_pMediator( nullptr ), m_pConfig( pConfig ), m_bStreaming( false )
{
#ifdef USE_MEDIATOR_THREAD
m_pMediator = new MediatorThread(this);
#endif
if ( m_pConfig->iBuffersize <= 0 )
if( m_pConfig->iBuffersize <= 0 )
m_pConfig->iBuffersize = ITAPortaudioInterface::GetPreferredBufferSize();
m_pITAPA = new ITAPortaudioInterface( m_pConfig->dSampleRate, m_pConfig->iBuffersize );
// An diesen Einstellungen ist nicht mehr zu drehen ...
m_oOutputStreamProps.dSamplerate = m_pConfig->dSampleRate;
m_oOutputStreamProps.uiBlocklength = (unsigned int) m_pConfig->iBuffersize;
m_oOutputStreamProps.uiChannels = (unsigned int) m_pConfig->iOutputChannels;
m_oOutputStreamProps.uiBlocklength = ( unsigned int ) m_pConfig->iBuffersize;
m_oOutputStreamProps.uiChannels = ( unsigned int ) m_pConfig->iOutputChannels;
}
CVAPortaudioBackend::~CVAPortaudioBackend()
......@@ -58,11 +58,11 @@ ITADatasource* CVAPortaudioBackend::getInputStreamDatasource() const {
return m_pITAPA->GetRecordDatasource();
}
void CVAPortaudioBackend::setOutputStreamDatasource(ITADatasource* pDatasource)
void CVAPortaudioBackend::setOutputStreamDatasource( ITADatasource* pDatasource )
{
ITAPortaudioInterface::ITA_PA_ERRORCODE e;
if ((e = m_pITAPA->SetPlaybackDatasource(pDatasource)) != ITAPortaudioInterface::ITA_PA_NO_ERROR)
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
if( ( e = m_pITAPA->SetPlaybackDatasource( pDatasource ) ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
}
void CVAPortaudioBackend::initialize()
......@@ -77,7 +77,7 @@ void CVAPortaudioBackend::initialize()
void CVAPortaudioBackend::threadInitialize()
{
ITAPortaudioInterface::ITA_PA_ERRORCODE e;
int iDriverID = -1;
try
{
......@@ -115,7 +115,7 @@ void CVAPortaudioBackend::threadInitialize()
ITA_EXCEPT1( INVALID_PARAMETER, "Samplerate " + DoubleToString( m_pConfig->dSampleRate ) + " is invalid for this audio device." );
m_oOutputStreamProps.uiBlocklength = ( unsigned int ) m_pConfig->iBuffersize;
m_oOutputStreamProps.uiChannels = ( unsigned int )m_pITAPA->GetNumOutputChannels( iDriverID );
m_oOutputStreamProps.uiChannels = ( unsigned int ) m_pITAPA->GetNumOutputChannels( iDriverID );
}
void CVAPortaudioBackend::finalize()
......@@ -130,8 +130,8 @@ void CVAPortaudioBackend::finalize()
void CVAPortaudioBackend::threadFinalize() {
ITAPortaudioInterface::ITA_PA_ERRORCODE e;
if ((e = m_pITAPA->Finalize()) != ITAPortaudioInterface::ITA_PA_NO_ERROR)
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
if( ( e = m_pITAPA->Finalize() ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
}
bool CVAPortaudioBackend::isStreaming() {
......@@ -150,16 +150,20 @@ void CVAPortaudioBackend::startStreaming()
#endif // USE_MEDIATOR_THREAD
}
void CVAPortaudioBackend::threadStartStreaming() {
void CVAPortaudioBackend::threadStartStreaming()
{
ITAPortaudioInterface::ITA_PA_ERRORCODE e;
if ((e = m_pITAPA->Open()) != ITAPortaudioInterface::ITA_PA_NO_ERROR)
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
if( ( e = m_pITAPA->Open() ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
if ((e = m_pITAPA->Start()) != ITAPortaudioInterface::ITA_PA_NO_ERROR) {
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
if( ( e = m_pITAPA->Start() ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
{
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
m_bStreaming = false;
} else {
}
else
{
m_bStreaming = true;
}
}
......@@ -172,118 +176,120 @@ void CVAPortaudioBackend::stopStreaming()
threadStopStreaming();
#endif // USE_MEDIATOR_THREAD
// [fwe] Wichtig: Direkt die Streaming-Flag erst lschen, wenn wirklich alles zuende ist
m_bStreaming = true;
assert( m_bStreaming == false );
}
void CVAPortaudioBackend::threadStopStreaming() {
void CVAPortaudioBackend::threadStopStreaming()
{
ITAPortaudioInterface::ITA_PA_ERRORCODE e;
if ((e = m_pITAPA->Stop()) != ITAPortaudioInterface::ITA_PA_NO_ERROR) {
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
m_bStreaming = true;
} else {
if( ( e = m_pITAPA->Stop() ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
{
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
}
else
{
m_bStreaming = false;
}
if ((e = m_pITAPA->Close()) != ITAPortaudioInterface::ITA_PA_NO_ERROR)
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
if( ( e = m_pITAPA->Close() ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
}
/* TODO stienen: klren, ob wir einen Mediator fr Portaudio berhaupt bentigen
CVAPortaudioBackend::MediatorThread::MediatorThread(CVAPortaudioBackend* pParent)
: m_pParent(pParent),
m_iOperation(OPERATION_NOTHING),
// TODO: What about the Posix-Flag in VistaThreadEvent?
m_evStart(false),
m_evFinish(false)
m_iOperation(OPERATION_NOTHING),
// TODO: What about the Posix-Flag in VistaThreadEvent?
m_evStart(false),
m_evFinish(false)
{
SetThreadName("VACore::ASIOMediatorThread");
Run();
SetThreadName("VACore::ASIOMediatorThread");
Run();
}
CVAPortaudioBackend::MediatorThread::~MediatorThread() {
m_iOperation = OPERATION_STOP_THREAD;
m_evStart.SignalEvent();
StopGently(true);
m_iOperation = OPERATION_STOP_THREAD;
m_evStart.SignalEvent();
StopGently(true);
}
int CVAPortaudioBackend::MediatorThread::doOperation(int iOperation) {
m_iOperation = iOperation;
m_evStart.SignalEvent();
m_evFinish.WaitForEvent(true);
m_evFinish.ResetThisEvent();
if (m_iResult != 0) {
// Rethrow exception
throw m_oException;
}
m_iOperation = iOperation;
m_evStart.SignalEvent();
m_evFinish.WaitForEvent(true);
m_evFinish.ResetThisEvent();
if (m_iResult != 0) {
// Rethrow exception
throw m_oException;
}
return 0;
return 0;
}
int CVAPortaudioBackend::MediatorThread::doInitialize() {
return doOperation(OPERATION_INITIALIZE);
return doOperation(OPERATION_INITIALIZE);
}
int CVAPortaudioBackend::MediatorThread::doFinalize() {
return doOperation(OPERATION_FINALIZE);
return doOperation(OPERATION_FINALIZE);
}
int CVAPortaudioBackend::MediatorThread::doStartStreaming() {
return doOperation(OPERATION_START_STREAMING);
return doOperation(OPERATION_START_STREAMING);
}
int CVAPortaudioBackend::MediatorThread::doStopStreaming() {
return doOperation(OPERATION_STOP_STREAMING);
return doOperation(OPERATION_STOP_STREAMING);
}
ITAException CVAPortaudioBackend::MediatorThread::getException() const {
return m_oException;
return m_oException;
}
bool CVAPortaudioBackend::MediatorThread::LoopBody() {
m_evStart.WaitForEvent(true);
if (m_iOperation == OPERATION_STOP_THREAD) {
IndicateLoopEnd();
return true;
}
m_evStart.WaitForEvent(true);
if (m_iOperation == OPERATION_STOP_THREAD) {
IndicateLoopEnd();
return true;
}
m_evStart.ResetThisEvent();
m_evStart.ResetThisEvent();
m_iResult = 0;
m_iResult = 0;
try {
switch (m_iOperation) {
case OPERATION_INITIALIZE:
m_pParent->threadInitialize();
break;
try {
switch (m_iOperation) {
case OPERATION_INITIALIZE:
m_pParent->threadInitialize();
break;
case OPERATION_FINALIZE:
m_pParent->threadFinalize();
break;
case OPERATION_FINALIZE:
m_pParent->threadFinalize();
break;
case OPERATION_START_STREAMING:
m_pParent->threadStartStreaming();
break;
case OPERATION_START_STREAMING:
m_pParent->threadStartStreaming();
break;
case OPERATION_STOP_STREAMING:
m_pParent->threadStopStreaming();
break;
}
case OPERATION_STOP_STREAMING:
m_pParent->threadStopStreaming();
break;
}
} catch (ITAException& e) {
m_iResult = -1;
m_oException = e;
} catch (...) {
// Hier sollte nie etwas ankommen...
assert( false );
}
} catch (ITAException& e) {
m_iResult = -1;
m_oException = e;
} catch (...) {
// Hier sollte nie etwas ankommen...
assert( false );
}
m_evFinish.SignalEvent();
m_evFinish.SignalEvent();
// No yield.
return false;
// No yield.
return false;
}
*/
......@@ -51,8 +51,6 @@
#include <tbb/atomic.h>
#include <tbb/concurrent_queue.h>
//static CVAAudioRendererDefaultFactory< CVABinauralFreeFieldAudioRenderer > g_oFactoryCVABinauralFreeFieldAudioRenderer( "BinauralFreeField" );
class CVABFFSoundPath : public CVAPoolObject
{
public:
......@@ -343,20 +341,28 @@ void CVABinauralFreeFieldAudioRenderer::Init( const CVAStruct& oArgs )
void CVABinauralFreeFieldAudioRenderer::Reset()
{
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Received reset call, indicating reset now" );
ctxAudio.m_iResetFlag = 1; // Request reset
if( ctxAudio.m_iStatus == 0 )
{
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Was not streaming, will reset manually" );
// if no streaming active, reset manually
//SyncInternalData();
ResetInternalData();
}
else
{
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Still streaming, will now wait for reset acknownledge" );
}
// Wait for last streaming block before internal reset
while( ctxAudio.m_iResetFlag != 2 )
{
VASleep( 10 ); // Wait for acknowledge
}
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Operation reset has green light, clearing items" );
// Iterate over sound pathes and free items
std::list< CVABFFSoundPath* >::iterator it = m_lSoundPaths.begin();
......@@ -404,6 +410,8 @@ void CVABinauralFreeFieldAudioRenderer::Reset()
}
ctxAudio.m_iResetFlag = 0; // Enter normal mode
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Reset successful" );
}
void CVABinauralFreeFieldAudioRenderer::UpdateScene( CVASceneState* pNewSceneState )
......@@ -606,8 +614,11 @@ void CVABinauralFreeFieldAudioRenderer::ManageSoundPaths( const CVASceneState* p
void CVABinauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStreamInfo )
{
// If streaming is active, set to 1
ctxAudio.m_iStatus = 1;
if( ctxAudio.m_iStatus == 0 )
{
// If streaming is active, set to 1
ctxAudio.m_iStatus = 1;
}
// Schallpfade abgleichen
SyncInternalData();
......@@ -624,23 +635,25 @@ void CVABinauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStr
// Check for reset request
if( ctxAudio.m_iResetFlag == 1 )
{
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Process stream detecting reset request, will reset internally now" );
ResetInternalData();
return;
}
else if( ctxAudio.m_iResetFlag == 2 )
{
// Reset active, skip until finished
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Process stream detecting ongoing reset, will stop processing here" );
return;
}
SampleTrajectoriesInternal( dListenerTime );
std::map< int, CVABFFListener* >::iterator lit = m_mListeners.begin();
while( lit != m_mListeners.end() )
std::list< CVABFFListener* >::iterator lit = ctxAudio.m_lListeners.begin();
while( lit != ctxAudio.m_lListeners.end() )
{
lit->second->psfOutput->zero();
lit++;
CVABFFListener* pListener( *( lit++ ) );
pListener->psfOutput->zero();
}
// Update sound pathes
......@@ -728,27 +741,27 @@ void CVABinauralFreeFieldAudioRenderer::ProcessStream( const ITAStreamInfo* pStr
}
// TODO: Select active listener
if( !m_mListeners.empty() )
if( !ctxAudio.m_lListeners.empty() )
{
CVABFFListener* pActiveListener = m_mListeners.begin()->second;
fm_copy( pfOutputChL, ( *pActiveListener->psfOutput )[0].data(), m_uiBlocklength );
fm_copy( pfOutputChR, ( *pActiveListener->psfOutput )[1].data(), m_uiBlocklength );
}
CVABFFListener* pActiveListener = *( ctxAudio.m_lListeners.begin() );
fm_copy( pfOutputChL, ( *pActiveListener->psfOutput )[ 0 ].data(), m_uiBlocklength );
fm_copy( pfOutputChR, ( *pActiveListener->psfOutput )[ 1 ].data(), m_uiBlocklength );
// Listener dumping
if( m_iDumpListenersFlag > 0 )
{
std::map< int, CVABFFListener* >::iterator it = m_mListeners.begin();
while( it != m_mListeners.end() )
// Listener dumping
if( m_iDumpListenersFlag > 0 )
{
CVABFFListener* pListener = it++->second;
pListener->psfOutput->mul_scalar( float( m_dDumpListenersGain ) );
pListener->pListenerOutputAudioFileWriter->write( pListener->psfOutput );
}
std::map< int, CVABFFListener* >::iterator it = m_mListeners.begin();
while( it != m_mListeners.end() )
{
CVABFFListener* pListener = it++->second;
pListener->psfOutput->mul_scalar( float( m_dDumpListenersGain ) );
pListener->pListenerOutputAudioFileWriter->write( pListener->psfOutput );
}
// Ack on dump stop
if( m_iDumpListenersFlag == 2 )
m_iDumpListenersFlag = 0;
// Ack on dump stop
if( m_iDumpListenersFlag == 2 )
m_iDumpListenersFlag = 0;
}
}
IncrementWritePointer();
......@@ -772,7 +785,7 @@ void CVABinauralFreeFieldAudioRenderer::UpdateTrajectories()
if( pMotionNew && ( pMotionNew != pMotionCur ) )
{
VA_TRACE( "CVABinauralFreeFieldAudioRenderer", "Source " << iSourceID << " new motion state" );
VA_TRACE( "VABinauralFreeFieldAudioRenderer", "Source " << iSourceID << " new motion state" );
pSource->pMotionModel->InputMotionKey( pMotionNew );
}
}
......@@ -791,7 +804,7 @@ void CVABinauralFreeFieldAudioRenderer::UpdateTrajectories()
if( pMotionNew && ( pMotionNew != pMotionCur ) )
{
VA_TRACE( "CVABinauralFreeFieldAudioRenderer", "Listener " << iListenerID << " new position " );// << *pMotionNew);
VA_TRACE( "VABinauralFreeFieldAudioRenderer", "Listener " << iListenerID << " new position " );// << *pMotionNew);
pListener->pMotionModel->InputMotionKey( pMotionNew );
}
}
......@@ -811,7 +824,7 @@ void CVABinauralFreeFieldAudioRenderer::SampleTrajectoriesInternal( double dTime
}
bValid = true;
for( std::list< CVABFFListener* >::iterator it = ctxAudio.m_lListener.begin(); it != ctxAudio.m_lListener.end(); ++it )
for( std::list< CVABFFListener* >::iterator it = ctxAudio.m_lListeners.begin(); it != ctxAudio.m_lListeners.end(); ++it )
{
CVABFFListener* pListener = *it;
......@@ -829,7 +842,7 @@ CVABFFSoundPath* CVABinauralFreeFieldAudioRenderer::CreateSoundPath( CVABFFSourc
assert( !pSource->bDeleted && !pListener->bDeleted );
VA_VERBOSE( "CVABinauralFreeFieldAudioRenderer", "Creating sound path from source " << iSourceID << " -> listener " << iListenerID);
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Creating sound path from source " << iSourceID << " -> listener " << iListenerID);
CVABFFSoundPath* pPath = dynamic_cast<CVABFFSoundPath*>( m_pSoundPathPool->RequestObject() );
......@@ -854,7 +867,7 @@ CVABFFSoundPath* CVABinauralFreeFieldAudioRenderer::CreateSoundPath( CVABFFSourc
void CVABinauralFreeFieldAudioRenderer::DeleteSoundPath( CVABFFSoundPath* pPath )
{
VA_VERBOSE( "CVABinauralFreeFieldAudioRenderer", "Marking sound path from source " << pPath->pSource->pData->iID << " -> listener " << pPath->pListener->pData->iID << " for deletion");
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Marking sound path from source " << pPath->pSource->pData->iID << " -> listener " << pPath->pListener->pData->iID << " for deletion");
pPath->bDelete = true;
pPath->RemoveReference();
......@@ -863,7 +876,7 @@ void CVABinauralFreeFieldAudioRenderer::DeleteSoundPath( CVABFFSoundPath* pPath
CVABinauralFreeFieldAudioRenderer::CVABFFListener* CVABinauralFreeFieldAudioRenderer::CreateListener( const int iID, const CVAListenerState* pListenerState )
{
VA_VERBOSE( "CVABinauralFreeFieldAudioRenderer", "Creating listener with ID " << iID );
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Creating listener with ID " << iID );
CVABFFListener* pListener = dynamic_cast<CVABFFListener*>( m_pListenerPool->RequestObject() ); // Reference = 1
......@@ -891,7 +904,7 @@ CVABinauralFreeFieldAudioRenderer::CVABFFListener* CVABinauralFreeFieldAudioRend
void CVABinauralFreeFieldAudioRenderer::DeleteListener( int iListenerID )
{
VA_VERBOSE( "CVABinauralFreeFieldAudioRenderer", "Marking listener with ID " << iListenerID << " for removal" );
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Marking listener with ID " << iListenerID << " for removal" );
std::map< int, CVABFFListener* >::iterator it = m_mListeners.find( iListenerID );
CVABFFListener* pListener = it->second;
m_mListeners.erase( it );
......@@ -906,7 +919,7 @@ void CVABinauralFreeFieldAudioRenderer::DeleteListener( int iListenerID )
CVABinauralFreeFieldAudioRenderer::CVABFFSource* CVABinauralFreeFieldAudioRenderer::CreateSource( int iID, const CVASoundSourceState* pSourceState )
{
VA_VERBOSE( "CVABinauralFreeFieldAudioRenderer", "Creating source with ID " << iID );
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Creating source with ID " << iID );
CVABFFSource* pSource = dynamic_cast< CVABFFSource* >( m_pSourcePool->RequestObject() );
pSource->pData = m_pCore->GetSceneManager()->GetSoundSourceDesc(iID);
......@@ -927,7 +940,7 @@ CVABinauralFreeFieldAudioRenderer::CVABFFSource* CVABinauralFreeFieldAudioRender
void CVABinauralFreeFieldAudioRenderer::DeleteSource( int iSourceID )
{
VA_VERBOSE( "CVABinauralFreeFieldAudioRenderer", "Marking source with ID " << iSourceID << " for removal" );
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Marking source with ID " << iSourceID << " for removal" );
std::map< int, CVABFFSource* >::iterator it = m_mSources.find( iSourceID );
if( it == m_mSources.end() ) // Not found in internal list ...
......@@ -992,7 +1005,7 @@ void CVABinauralFreeFieldAudioRenderer::SyncInternalData()
while( citl != pUpdate->vDelListeners.end() )
{
CVABFFListener* pListener( *citl++ );
ctxAudio.m_lListener.remove( pListener );
ctxAudio.m_lListeners.remove( pListener );
pListener->pData->RemoveReference();
pListener->RemoveReference();
}
......@@ -1003,7 +1016,7 @@ void CVABinauralFreeFieldAudioRenderer::SyncInternalData()
CVABFFListener* pListener( *citl++ );
pListener->AddReference();
pListener->pData->AddReference();
ctxAudio.m_lListener.push_back( pListener );
ctxAudio.m_lListeners.push_back( pListener );
}
pUpdate->RemoveReference();
......@@ -1014,6 +1027,8 @@ void CVABinauralFreeFieldAudioRenderer::SyncInternalData()
void CVABinauralFreeFieldAudioRenderer::ResetInternalData()
{
VA_VERBOSE( "VABinauralFreeFieldAudioRenderer", "Resetting internally" );
std::list< CVABFFSoundPath* >::const_iterator citp = ctxAudio.m_lSoundPaths.begin();
while( citp != ctxAudio.m_lSoundPaths.end() )
{
......@@ -1022,14 +1037,14 @@ void CVABinauralFreeFieldAudioRenderer::ResetInternalData()
}
ctxAudio.m_lSoundPaths.clear();
std::list< CVABFFListener* >::const_iterator itl=ctxAudio.m_lListener.begin();
while( itl !=ctxAudio.m_lListener.end() )
std::list< CVABFFListener* >::const_iterator itl=ctxAudio.m_lListeners.begin();
while( itl !=ctxAudio.m_lListeners.end() )
{
CVABFFListener* pListener( *itl++ );
pListener->pData->RemoveReference();
pListener->RemoveReference();
}
ctxAudio.m_lListener.clear();
ctxAudio.m_lListeners.clear();
std::list< CVABFFSource* >::const_iterator cits = ctxAudio.m_lSources.begin();
while( cits != ctxAudio.m_lSources.end() )
......@@ -1282,22 +1297,26 @@ void CVABFFSoundPath::UpdateHRIR( const CVAListenerState::CVAAnthropometricParam
oHRIRStateCur = oHRIRStateNew;
}
// Calculate individualized ITD based on anthropometric data
// Source: ???
double daw =-8.7231e-4;
double dbw = 0.0029;
double dah =-3.942e-4;
double dbh = 6.0476e-4;
double dad = 4.2308e-4;
double dbd = oAnthroParameters.GetHeadDepthParameterFromLUT( oAnthroParameters.dHeadDepth );
double dDeltaWidth = oAnthroParameters.dHeadWidth - pHRIRDataNew->GetProperties()->oAnthroParams.dHeadWidth;
double dDeltaHeight = oAnthroParameters.dHeadHeight - pHRIRDataNew->GetProperties()->oAnthroParams.dHeadHeight;
double dDeltaDepth = oAnthroParameters.dHeadDepth - pHRIRDataNew->GetProperties()->oAnthroParams.dHeadDepth;
double dPhiRad = oRelations.dAzimuthL2S * ITAConstants::PI_F / 180.0;
double dThetaRad = -( oRelations.dElevationL2S * ITAConstants::PI_F / 180.0 - ITAConstants::PI_F / 2.0f );
double dAmplitude = dPhiRad * ( dDeltaWidth * ( dThetaRad * dThetaRad * daw + dThetaRad * dbw ) + dDeltaHeight * ( dThetaRad * dThetaRad * dah + dThetaRad * dbh ) + dDeltaDepth * ( dThetaRad * dThetaRad * dad + dThetaRad * dbd ) );
double dITDCorrectionShift = std::sin( dPhiRad ) * dAmplitude;
double dITDCorrectionShift = .0f;
if( pHRIRDataNew )
{
// Calculate individualized ITD based on anthropometric data
// Source: ???
double daw = -8.7231e-4;
double dbw = 0.0029;
double dah = -3.942e-4;
double dbh = 6.0476e-4;
double dad = 4.2308e-4;
double dbd = oAnthroParameters.GetHeadDepthParameterFromLUT( oAnthroParameters.dHeadDepth );
double dDeltaWidth = oAnthroParameters.dHeadWidth - pHRIRDataNew->GetProperties()->oAnthroParams.dHeadWidth;
double dDeltaHeight = oAnthroParameters.dHeadHeight - pHRIRDataNew->GetProperties()->oAnthroParams.dHeadHeight;
double dDeltaDepth = oAnthroParameters.dHeadDepth - pHRIRDataNew->GetProperties()->oAnthroParams.dHeadDepth;
double dPhiRad = oRelations.dAzimuthL2S * ITAConstants::PI_F / 180.0;
double dThetaRad = -( oRelations.dElevationL2S * ITAConstants::PI_F / 180.0 - ITAConstants::PI_F / 2.0f );
double dAmplitude = dPhiRad * ( dDeltaWidth * ( dThetaRad * dThetaRad * daw + dThetaRad * dbw ) + dDeltaHeight * ( dThetaRad * dThetaRad * dah + dThetaRad * dbh ) + dDeltaDepth * ( dThetaRad * dThetaRad * dad + dThetaRad * dbd ) );
dITDCorrectionShift = std::sin( dPhiRad ) * dAmplitude;
}
// Apply individualized delay
float fPreviousDelayTimeL = pVariableDelayLineChL->GetNewDelayTime();
float fPreviousDelayTimeR = pVariableDelayLineChR->GetNewDelayTime();
......
......@@ -342,7 +342,7 @@ private:
tbb::concurrent_queue< CVABFFUpdateMessage* > m_qpUpdateMessages; //!< Update messages list
std::list< CVABFFSoundPath* > m_lSoundPaths; //!< List of sound paths
std::list< CVABFFSource* > m_lSources; //!< List of sources
std::list< CVABFFListener* > m_lListener; //!< List of listeners
std::list< CVABFFListener* > m_lListeners; //!< List of listeners
ITASampleBuffer m_sbTempL; //!< Temporally used buffer to store a block of samples during processing (left ear)
ITASampleBuffer m_sbTempR; //!< Temporally used buffer to store a block of samples during processing (right ear)
ITAAtomicInt m_iResetFlag; //!< Reset status flag: 0=normal_op, 1=reset_request, 2=reset_ack
......
......@@ -33,12 +33,14 @@
#include <ITASampleFrame.h>
#include <ITAStreamInfo.h>
#include <ITAFastMath.h>
#include <ITAConstants.h>