Commit 8ea5980c authored by Daniel Filbert's avatar Daniel Filbert Committed by Lucas Moesch

fixing Ambisonics position calculations

parent d940a726
......@@ -104,7 +104,7 @@ public:
CVAAmbisonicsFreeFieldAudioRenderer::CVAAFFSource* pSource;
CVAAmbisonicsFreeFieldAudioRenderer::CVAAFFListener* pListener;
CVASourceReceiverMetrics oRelations; //!< Informationen on source and receiver relations (distances & angles)
CVASourceReceiverMetrics oRelations; //!< Informations on source and receiver relations (distances & angles)
CDirectivityState oDirectivityStateCur;
CDirectivityState oDirectivityStateNew;
......@@ -238,6 +238,8 @@ CVAAmbisonicsFreeFieldAudioRenderer::CVAAmbisonicsFreeFieldAudioRenderer( const
double dSampleRate = m_pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate;
int iBlockLength = m_pCore->GetCoreConfig()->oAudioDriverConfig.iBuffersize;
m_vecCaveCenterPos.Set(0.0f, 1.27f, 0.0f);
m_pdsOutput = new ITADatasourceRealization( m_iNumChannels, dSampleRate, iBlockLength );
m_pdsOutput->SetStreamEventHandler( this );
......@@ -428,6 +430,24 @@ void CVAAmbisonicsFreeFieldAudioRenderer::UpdateScene( CVASceneState* pNewSceneS
// Bewegungsinformationen der Quellen und Hrer aktualisieren
UpdateTrajectories();
// Positionen von Hoerer in virtueller Scene aktualisieren
int iListenerID;
if (m_pNewSceneState->GetNumListeners() > 0)
{
std::vector< int > viListenerIDs;
m_pNewSceneState->GetListenerIDs(&viListenerIDs);
// Use first listener as the user of Ambisonics
iListenerID = viListenerIDs[0];
m_vUserPosVirtualScene = m_pNewSceneState->GetReceiverState(iListenerID)->GetMotionState()->GetPosition();
VAVec3 p, v, u;
m_oParams.pCore->GetSoundReceiverRealWorldPositionOrientationVU(iListenerID, p, v, u);
m_vUserPosRealWorld.Set(float(p.x), float(p.y), float(p.z));
// Define reproduction system in virtual scene
m_vReproSystemVirtualPosition = m_vUserPosVirtualScene - m_vUserPosRealWorld;
}
// Entitten der Schallpfade aktualisieren
UpdateSoundPaths();
......@@ -602,6 +622,21 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ManageSoundPaths( const CVASceneState*
return;
}
double CVAAmbisonicsFreeFieldAudioRenderer::dAzimuthSource2ReproCenter( const CVAMotionState* pMotionState )
{
// VAVec3 vPosSource2ReceiverVirtualScene = pMotionState->GetPosition() - m_vUserPosVirtualScene;
return GetAzimuthOnTarget_DEG(m_vecCaveCenterPos, pMotionState->GetView(), pMotionState->GetUp(), pMotionState->GetPosition());
}
double CVAAmbisonicsFreeFieldAudioRenderer::dElevationSource2ReproCenter( const CVAMotionState* pMotionState )
{
// VAVec3 vPosSource2ReceiverVirtualScene = pMotionState->GetPosition() - m_vUserPosVirtualScene;
return GetElevationOnTarget_DEG(m_vecCaveCenterPos, pMotionState->GetView(), pMotionState->GetUp(), pMotionState->GetPosition());
}
void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream( ITADatasourceRealization*, const ITAStreamInfo* pStreamInfo )
{
if( ctxAudio.m_iStatus == 0 )
......@@ -728,9 +763,12 @@ void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream( ITADatasourceReal
pPath->pThirdOctaveFilterBank->Process( psbInput->data(), ctxAudio.m_sbTemp.data() );
pPath->pVariableDelayLineCh->Process( &( ctxAudio.m_sbTemp ), &( ctxAudio.m_sbTemp ) );
int iID = pPath->pSource->pData->iID;
CVASoundSourceState* pState = m_pCurSceneState->GetSoundSourceState(iID);
const CVAMotionState* pMotionState = pState->GetMotionState();
//std::vector<double> gains = vdRealvalued_basefunctions( (90-pPath->oRelations.dElevationL2S), pPath->oRelations.dAzimuthL2S, m_iMaxOrder);
std::vector<double> gains = SHRealvaluedBasefunctions( ( 90 - pPath->oRelations.dElevationL2S ) / 180 * 3.14159265359, pPath->oRelations.dAzimuthL2S / 180 * 3.14159265359, m_iMaxOrder );
std::vector<double> gains = SHRealvaluedBasefunctions((90 - dElevationSource2ReproCenter(pMotionState)) / 180 * 3.14159265359, dAzimuthSource2ReproCenter(pMotionState) / 180 * 3.14159265359, m_iMaxOrder);
for( int i = 0; i < m_iNumChannels; i++ )
{
......
......@@ -123,6 +123,9 @@ public:
void onStartDumpListeners( const std::string& sFilenameFormat );
void onStopDumpListeners();
double dAzimuthSource2ReproCenter( const CVAMotionState* pMotionState );
double dElevationSource2ReproCenter( const CVAMotionState* pMotionState );
protected:
//! Internal source representation
......@@ -277,6 +280,12 @@ private:
CVASceneState* m_pCurSceneState;
CVASceneState* m_pNewSceneState;
VAVec3 m_vUserPosVirtualScene; //!< Position des Hoerers in der virtuellen Umgebung
VAVec3 m_vUserPosRealWorld; //!< Position des Hrers in der CAVE (oder im Reproduktionssystem)
VAVec3 m_vReproSystemVirtualPosition; //!< Position der CAVE (oder des Reproduktionssystems) in der virtuellen Welt. Center position of loudspeaker array.
VAVec3 m_vecCaveCenterPos; //!< Erwartete Hoererposition bzw. Punkt fr den Ambisonics das Schallfeld berechnet
int m_iCurGlobalAuralizationMode;
IVAObjectPool* m_pSoundPathPool;
......
......@@ -51,10 +51,10 @@ CVAAmbisonicsReproduction::CVAAmbisonicsReproduction( const CVAAudioReproduction
if( sReproCenterPos == "AUTO" )
{
//Mittelpunkt aus der ersten LS Configuration berechnen
m_vpTargetOutputs[ 0 ];
m_v3ReproductionCenterPos.Set( 0, 0, 0 );
//m_vpTargetOutputs[ 0 ];
m_v3ReproductionCenterPos.Set( 0, 1.27, 0 );
// VA_EXCEPT2(NOT_IMPLEMENTED, "Automatic reproduction center calculation not implemented, please provide 3-dim vector with key 'ReproductionCenterPos' in reproduction configuration");
VA_WARN( this, "Reproduction center set to 0,0,0" );
VA_WARN( this, "Reproduction center set to 0,1.27,0" );
}
else
{
......@@ -93,7 +93,7 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
double dAzimuth, dElevation;
// TODO Center Position aus Config?
VAVec3 va3Origin( 0, 0, 0 );
//VAVec3 va3Origin( 0, 1.27, 0 );
VAVec3 va3View( 0, 0, -1 );
VAVec3 va3Up( 0, 1, 0 );
......@@ -104,8 +104,8 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
{
const CVAHardwareDevice* pDevice = m_pOutput->vpDevices[ k ];
dAzimuth = GetAzimuthOnTarget_DEG( va3Origin, va3View, va3Up, pDevice->vPos ) / 180 * ITAConstants::PI_D;
dElevation = GetElevationOnTarget_DEG( va3Origin, va3View, va3Up, pDevice->vPos ) / 180 * ITAConstants::PI_D;
dAzimuth = GetAzimuthOnTarget_DEG(m_v3ReproductionCenterPos, va3View, va3Up, pDevice->vPos) / 180 * ITAConstants::PI_D;
dElevation = GetElevationOnTarget_DEG(m_v3ReproductionCenterPos, va3View, va3Up, pDevice->vPos) / 180 * ITAConstants::PI_D;
vdYParts = SHRealvaluedBasefunctions( ITAConstants::PI_D / 2 - dElevation, dAzimuth, m_iAmbisonicsTruncationOrder );
for( int l = 0; l < vdYParts.size(); l++ )
......@@ -132,10 +132,6 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
{
const VAVec3& v3LSPos( pTargetOutput->vpDevices[ k ]->vPos );
VAVec3 v3ViewDummy, v3UpDummy;
double dAzimuth = GetAzimuthOnTarget_DEG( m_v3ReproductionCenterPos, v3ViewDummy, v3UpDummy, v3LSPos );
double dElevation = GetAzimuthOnTarget_DEG( m_v3ReproductionCenterPos, v3ViewDummy, v3UpDummy, v3LSPos );
// todo calculate gain @mko
if( j == 0 && k == 0 )
VA_WARN( "AmbisonicsReproduction", "No dynamic HOA matrix calculation based on LS configuration available, using pre-calculated matrix for ITA VR lab" );
......
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