Commit cc9ae53e authored by Michael Kohnen's avatar Michael Kohnen Committed by Lucas Moesch

development on ambisonics

parent 8ea5980c
......@@ -440,12 +440,19 @@ void CVAAmbisonicsFreeFieldAudioRenderer::UpdateScene( CVASceneState* pNewSceneS
// Use first listener as the user of Ambisonics
iListenerID = viListenerIDs[0];
m_vUserPosVirtualScene = m_pNewSceneState->GetReceiverState(iListenerID)->GetMotionState()->GetPosition();
m_vUserViewVirtualScene = m_pNewSceneState->GetReceiverState(iListenerID)->GetMotionState()->GetView();
m_vUserUpVirtualScene = m_pNewSceneState->GetReceiverState(iListenerID)->GetMotionState()->GetUp();
VAVec3 p, v, u;
m_oParams.pCore->GetSoundReceiverRealWorldPositionOrientationVU(iListenerID, p, v, u);
m_vUserPosRealWorld.Set(float(p.x), float(p.y), float(p.z));
m_vUserPosRealWorld.Set(float(p.x), float(p.y), float(p.z));
m_vUserViewRealWorld.Set(float(v.x), float(v.y), float(v.z));
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_vReproSystemVirtualPosition = m_vUserPosVirtualScene - m_vUserPosRealWorld;
m_vReproSystemVirtualView = m_vUserViewVirtualScene - m_vUserViewRealWorld;
m_vReproSystemVirtualUp = m_vUserUpVirtualScene - m_vUserUpRealWorld;
}
// Entitten der Schallpfade aktualisieren
......
......@@ -284,6 +284,14 @@ private:
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_vUserViewVirtualScene;
VAVec3 m_vUserViewRealWorld;
VAVec3 m_vReproSystemVirtualView;
VAVec3 m_vUserUpVirtualScene;
VAVec3 m_vUserUpRealWorld;
VAVec3 m_vReproSystemVirtualUp;
VAVec3 m_vecCaveCenterPos; //!< Erwartete Hoererposition bzw. Punkt fr den Ambisonics das Schallfeld berechnet
int m_iCurGlobalAuralizationMode;
......
......@@ -28,12 +28,30 @@
CVAAmbisonicsReproduction::CVAAmbisonicsReproduction( const CVAAudioReproductionInitParams& oParams )
: m_oParams( oParams )
{
CVAConfigInterpreter conf( *( m_oParams.pConfig ) );
conf.ReqInteger( "TruncationOrder", m_iAmbisonicsTruncationOrder );
double dSampleRate = m_oParams.pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate;
int iBlockLength = oParams.pCore->GetCoreConfig()->oAudioDriverConfig.iBuffersize;
std::string sReproCenterPos;
for (size_t i = 0; i < m_oParams.vpOutputs.size(); i++)
{
const CVAHardwareOutput* pTargetOutput = m_oParams.vpOutputs[i];
if (!pTargetOutput->bEnabled)
VA_WARN(this, " " + pTargetOutput->sIdentifier + " is not enabled, no sound will be played back over this output");
if (pTargetOutput == nullptr)
VA_EXCEPT2(INVALID_PARAMETER, "Unrecognized output '" + pTargetOutput->sIdentifier + "' for Ambisonics reproduction");
m_vpTargetOutputs.push_back(pTargetOutput);
}
if (m_vpTargetOutputs.size()<1)
VA_EXCEPT2(INVALID_PARAMETER, "No output found for Ambisonics reproduction!");
// Configurable parameter from Core.ini
CVAConfigInterpreter conf(*(m_oParams.pConfig));
conf.ReqInteger( "TruncationOrder", m_iAmbisonicsTruncationOrder );
conf.OptBool("UseRemax", m_bUseRemax, true);
conf.OptString("ReproductionCenterPos", sReproCenterPos, "AUTO");
// Decoder input (B-Format with implicit channels)
m_pDecoderMatrixPatchBay = new ITAStreamPatchbay( dSampleRate, iBlockLength );
......@@ -46,15 +64,11 @@ CVAAmbisonicsReproduction::CVAAmbisonicsReproduction( const CVAAudioReproduction
m_vpTargetOutputs.push_back( pTargetOutput );
}
std::string sReproCenterPos;
conf.OptString( "ReproductionCenterPos", sReproCenterPos, "AUTO" );
if( sReproCenterPos == "AUTO" )
{
//Mittelpunkt aus der ersten LS Configuration berechnen
//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,1.27,0" );
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));
}
else
{
......@@ -72,6 +86,25 @@ CVAAmbisonicsReproduction::~CVAAmbisonicsReproduction()
m_pDecoderMatrixPatchBay = NULL;
}
void CVAAmbisonicsReproduction::GetCalculatedReproductionCenterPos(VAVec3 &vec3CalcPos)
{
int iNumberDevices=0;
VAVec3 vec3Old;
vec3CalcPos.Set(0, 0, 0);
vec3Old.Set(0,0,0);
for (int idxTO = 0; idxTO < m_vpTargetOutputs.size(); idxTO++)
{
for (int idxDev = 0; idxDev < m_vpTargetOutputs[idxTO]->vpDevices.size(); idxDev++)
{
iNumberDevices++;
vec3Old = vec3CalcPos;
vec3CalcPos = vec3Old + m_vpTargetOutputs[idxTO]->vpDevices[idxDev]->vPos;
}
}
vec3Old = vec3CalcPos;
vec3CalcPos.Set(vec3Old.x / iNumberDevices, vec3Old.y / iNumberDevices, vec3Old.z / iNumberDevices );
}
void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
{
CVAConfigInterpreter conf( *( m_oParams.pConfig ) );
......@@ -91,12 +124,8 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
Eigen::MatrixXd matY( m_pOutput->vpDevices.size(), ( m_iAmbisonicsTruncationOrder + 1 )*( m_iAmbisonicsTruncationOrder + 1 ) );
double dAzimuth, dElevation;
// TODO Center Position aus Config?
//VAVec3 va3Origin( 0, 1.27, 0 );
VAVec3 va3View( 0, 0, -1 );
VAVec3 va3Up( 0, 1, 0 );
std::vector<double> vdYParts;
// Gather matrix with loudspeaker position as (N_LS x 3);
......@@ -130,7 +159,7 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
int iCurrentOrder = ( int ) floor( sqrt( j ) );
for( size_t k = 0; k < pTargetOutput->GetPhysicalOutputChannels().size(); k++ )
{
const VAVec3& v3LSPos( pTargetOutput->vpDevices[ k ]->vPos );
//const VAVec3& v3LSPos( pTargetOutput->vpDevices[ k ]->vPos );
// todo calculate gain @mko
if( j == 0 && k == 0 )
......
......@@ -41,12 +41,11 @@ public:
int GetNumInputChannels() const;
int GetAmbisonicsTruncationOrder() const;
void UpdateScene( CVASceneState* pNewState );
/*bool Inverse(Eigen::MatrixXd vmIn, Eigen::MatrixXd vmOut);
bool SwapLine(Eigen::MatrixXd vmIn, int, int);*/
Eigen::MatrixXd CalculatePseudoInverse(Eigen::MatrixXd);
private:
void GetCalculatedReproductionCenterPos(VAVec3 &vec3CalcPos);
bool m_bUseRemax;
std::string m_sName;
CVAAudioReproductionInitParams m_oParams;
int m_iAmbisonicsTruncationOrder;
......
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