Commit 6b66085d authored by Michael Kohnen's avatar Michael Kohnen Committed by Lucas Moesch

Added rotation to Ambisonics in view up

parent cc9ae53e
......@@ -238,8 +238,7 @@ 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 );
......@@ -278,10 +277,29 @@ void CVAAmbisonicsFreeFieldAudioRenderer::Init( const CVAStruct& oArgs )
conf.ReqInteger( "TruncationOrder", m_iMaxOrder );
m_iNumChannels = ( m_iMaxOrder + 1 )*( m_iMaxOrder + 1 );
std::string sReproCenterPos;
conf.OptString("ReproductionCenterPos", sReproCenterPos, "AUTO");
if (sReproCenterPos == "AUTO")
{
//Mittelpunkt aus der ersten LS Configuration berechnen
//GetCalculatedReproductionCenterPos(m_v3ReproductionCenterPos);
//VA_WARN(this, "Ambisonics reproduction center set to " + std::to_string(m_v3ReproductionCenterPos.x) + ", " + std::to_string(m_v3ReproductionCenterPos.y) + ", " + std::to_string(m_v3ReproductionCenterPos.z));
m_vReproSystemRealPosition.Set(0, 1.27f, 0);
m_vReproSystemRealUp.Set(0, 1, 0);
m_vReproSystemRealView.Set(0, 0, -1);
}
else
{
//std::vector< std::string > vsPosComponents = splitString(sReproCenterPos, ',');
//assert(vsPosComponents.size() == 3);
//m_v3ReproductionCenterPos.Set(StringToFloat(vsPosComponents[0]), StringToFloat(vsPosComponents[1]), StringToFloat(vsPosComponents[2]));
}
std::string sVLDInterpolationAlgorithm;
conf.OptString( "SwitchingAlgorithm", sVLDInterpolationAlgorithm, "cubicspline" );
sVLDInterpolationAlgorithm = toLowercase( sVLDInterpolationAlgorithm );
if( sVLDInterpolationAlgorithm == "switch" )
m_iDefaultVDLSwitchingAlgorithm = CITAVariableDelayLine::SWITCH;
else if( sVLDInterpolationAlgorithm == "crossfade" )
......@@ -436,7 +454,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::UpdateScene( CVASceneState* pNewSceneS
{
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();
......@@ -450,9 +468,21 @@ void CVAAmbisonicsFreeFieldAudioRenderer::UpdateScene( CVASceneState* pNewSceneS
m_vUserUpRealWorld.Set(float(u.x), float(u.y), float(u.z));
// Define reproduction system in virtual scene
m_vReproSystemVirtualPosition = m_vUserPosVirtualScene - m_vUserPosRealWorld;
m_vReproSystemVirtualView = m_vUserViewVirtualScene - m_vUserViewRealWorld;
m_vReproSystemVirtualUp = m_vUserUpVirtualScene - m_vUserUpRealWorld;
m_vUserViewVirtualScene.Norm();
m_vUserViewRealWorld.Norm();
m_vReproSystemRealView.Norm();
m_vUserUpVirtualScene.Norm();
m_vUserUpRealWorld.Norm();
m_vReproSystemRealUp.Norm();
m_vReproSystemVirtualPosition = m_vUserPosVirtualScene - m_vUserPosRealWorld + m_vReproSystemRealPosition;
m_vReproSystemVirtualView = m_vUserViewVirtualScene - (m_vUserViewRealWorld - m_vReproSystemRealView);
m_vReproSystemVirtualUp = m_vUserUpVirtualScene - (m_vUserUpRealWorld - m_vReproSystemRealUp);
m_vReproSystemVirtualView.Norm();
m_vReproSystemVirtualUp.Norm();
}
// Entitten der Schallpfade aktualisieren
......@@ -633,14 +663,15 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ManageSoundPaths( const CVASceneState*
double CVAAmbisonicsFreeFieldAudioRenderer::dAzimuthSource2ReproCenter( const CVAMotionState* pMotionState )
{
// VAVec3 vPosSource2ReceiverVirtualScene = pMotionState->GetPosition() - m_vUserPosVirtualScene;
return GetAzimuthOnTarget_DEG(m_vecCaveCenterPos, pMotionState->GetView(), pMotionState->GetUp(), pMotionState->GetPosition());
return GetAzimuthOnTarget_DEG(m_vReproSystemVirtualPosition, m_vReproSystemVirtualView, m_vReproSystemVirtualUp, 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());
//return GetElevationOnTarget_DEG(m_vReproSystemVirtualPosition, pMotionState->GetView(), pMotionState->GetUp(), pMotionState->GetPosition());
return GetElevationOnTarget_DEG(m_vReproSystemVirtualPosition, m_vReproSystemVirtualView, m_vReproSystemVirtualUp, pMotionState->GetPosition());
}
......@@ -775,6 +806,11 @@ void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream( ITADatasourceReal
const CVAMotionState* pMotionState = pState->GetMotionState();
double ddedede = dElevationSource2ReproCenter(pMotionState);
double dsvdf = dAzimuthSource2ReproCenter(pMotionState);
VAVec3 fswdf = pMotionState->GetPosition();
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++ )
......
......@@ -283,16 +283,18 @@ private:
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_vReproSystemRealPosition; //!< Position of the reproduction center in the real world
VAVec3 m_vUserViewVirtualScene;
VAVec3 m_vUserViewRealWorld;
VAVec3 m_vReproSystemVirtualView;
VAVec3 m_vReproSystemRealView;
VAVec3 m_vUserUpVirtualScene;
VAVec3 m_vUserUpRealWorld;
VAVec3 m_vReproSystemVirtualUp;
VAVec3 m_vecCaveCenterPos; //!< Erwartete Hoererposition bzw. Punkt fr den Ambisonics das Schallfeld berechnet
VAVec3 m_vReproSystemRealUp;
//VAVec3 m_vecCaveCenterPos; //!< Erwartete Hoererposition bzw. Punkt fr den Ambisonics das Schallfeld berechnet
int m_iCurGlobalAuralizationMode;
......
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