Commit 58adedd8 authored by Michael Kohnen's avatar Michael Kohnen
Browse files

Adapted ambisonics reproduction, now working with pseudo-inv calculation and remax, not tested

parent eb08b373
...@@ -63,88 +63,6 @@ CVAAmbisonicsReproduction::CVAAmbisonicsReproduction( const CVAAudioReproduction ...@@ -63,88 +63,6 @@ CVAAmbisonicsReproduction::CVAAmbisonicsReproduction( const CVAAudioReproduction
m_v3ReproductionCenterPos.Set( StringToFloat( vsPosComponents[0] ), StringToFloat( vsPosComponents[1] ), StringToFloat( vsPosComponents[2] ) ); m_v3ReproductionCenterPos.Set( StringToFloat( vsPosComponents[0] ), StringToFloat( vsPosComponents[1] ), StringToFloat( vsPosComponents[2] ) );
} }
/*
Eigen::MatrixXd LS;
int idxm = 0;
LS.resize(9, 3);
int idxn = 0;
LS(idxm, idxn) = 0;
idxn++;
LS(idxm, idxn) = 0;
idxn++;
LS(idxm, idxn) = 1;
idxm++;
idxn = 0;
LS(idxm, idxn) = 0.9366;
idxn++;
LS(idxm, idxn) = 0;
idxn++;
LS(idxm, idxn) = 0.3504;
idxm++;
idxn = 0;
LS(idxm, idxn) = -0.5434;
idxn++;
LS(idxm, idxn) = -0.4622;
idxn++;
LS(idxm, idxn) = -0.7007;
idxm++;
idxn = 0;
LS(idxm, idxn) = -0.5611;
idxn++;
LS(idxm, idxn) = 0.6596;
idxn++;
LS(idxm, idxn) = -0.5;
idxm++;
idxn = 0;
LS(idxm, idxn) = 0.5434;
idxn++;
LS(idxm, idxn) = 0.4622;
idxn++;
LS(idxm, idxn) = -0.7007;
idxm++;
idxn = 0;
LS(idxm, idxn) = 0.1502;
idxn++;
LS(idxm, idxn) = 0.9245;
idxn++;
LS(idxm, idxn) = 0.3504;
idxm++;
idxn = 0;
LS(idxm, idxn) = -0.1502;
idxn++;
LS(idxm, idxn) = -0.9245;
idxn++;
LS(idxm, idxn) = 0.3504;
idxm++;
idxn = 0;
LS(idxm, idxn) = -0.9366;
idxn++;
LS(idxm, idxn) = 0;
idxn++;
LS(idxm, idxn) = 0.3504;
idxm++;
idxn = 0;
LS(idxm, idxn) = 0.5611;
idxn++;
LS(idxm, idxn) = -0.6596;
idxn++;
LS(idxm, idxn) = 0.5;
idxm++;
Eigen::MatrixXd pinvLS = CalculatePseudoInverse(LS);
int t = 4;
*/
return; return;
} }
...@@ -156,6 +74,8 @@ CVAAmbisonicsReproduction::~CVAAmbisonicsReproduction() ...@@ -156,6 +74,8 @@ CVAAmbisonicsReproduction::~CVAAmbisonicsReproduction()
void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p ) void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
{ {
CVAConfigInterpreter conf(*(m_oParams.pConfig));
m_pDecoderMatrixPatchBay->AddInput( p ); m_pDecoderMatrixPatchBay->AddInput( p );
int iNumConfiguredAmbisonicsChannels = ( m_iAmbisonicsTruncationOrder + 1 ) * ( m_iAmbisonicsTruncationOrder + 1 ); int iNumConfiguredAmbisonicsChannels = ( m_iAmbisonicsTruncationOrder + 1 ) * ( m_iAmbisonicsTruncationOrder + 1 );
...@@ -164,19 +84,39 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p ) ...@@ -164,19 +84,39 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
int iMaxPossibleAmbisonicsChannelNumber = min( int( p->GetNumberOfChannels() ), iNumConfiguredAmbisonicsChannels ); int iMaxPossibleAmbisonicsChannelNumber = min( int( p->GetNumberOfChannels() ), iNumConfiguredAmbisonicsChannels );
// Determine matrix (temp) std::string sOutput;
double dYInv[9][12] = conf.ReqString("Outputs", sOutput);
m_pOutput = m_oParams.pCore->GetCoreConfig()->oHardwareSetup.GetOutput(sOutput);
Eigen::MatrixXd matY(m_pOutput->vpDevices.size(), (m_iAmbisonicsTruncationOrder + 1)*(m_iAmbisonicsTruncationOrder + 1));
double dAzimuth, dElevation;
// TODO Center Position aus Config?
VAVec3 va3Origin(0, 0, 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);
for (int k = 0; k < m_pOutput->vpDevices.size(); k++)
{ {
{ 0.21281, 0.21281, 0.21281, 0.21281, 0.24789, 0.24789, 0.24789, 0.24789, 0.24623, 0.24623, 0.24623, 0.24623 }, const CVAHardwareDevice* pDevice = m_pOutput->vpDevices[k];
{ -0.00024028, -0.00024028, -0.00024028, -0.00024028, 0.19702, 0.19702, 0.19702, 0.19702, -0.19909, -0.19909, -0.19909, -0.19909 },
{ -0.22154, -0.22154, 0.22154, 0.22154, -0.2759, 0, 0.2759, 0, -0.27216, 0, 0.27216, 0 }, dAzimuth = GetAzimuthOnTarget_DEG(va3Origin, va3View, va3Up, pDevice->vPos) / 180 * ITAConstants::PI_D;
{ -0.22154, 0.22154, 0.22154, -0.22154, 0, 0.2759, 0, -0.2759, 0, 0.27216, 0, -0.27216 }, dElevation = GetElevationOnTarget_DEG(va3Origin, va3View, va3Up, pDevice->vPos) / 180 * ITAConstants::PI_D;
{ -0.00039878, 0.00039878, 0.00039878, -0.00039878, 0, 0.21491, 0, -0.21491, 0, -0.21686, 0, 0.21686 },
{ -0.00039878, -0.00039878, 0.00039878, 0.00039878, -0.21491, 0, 0.21491, 0, 0.21686, 0, -0.21686, 0 }, vdYParts = SHRealvaluedBasefunctions(ITAConstants::PI_D / 2 - dElevation, dAzimuth, m_iAmbisonicsTruncationOrder);
{ 0.042865, 0.042865, 0.042865, 0.042865, 0.11116, -0.097319, 0.11116, -0.097319, 0.10911, -0.096866, 0.10911, -0.096866 }, for (int l = 0; l < vdYParts.size(); l++)
{ 0.18306, -0.18306, 0.18306, -0.18306, 0, 0, 0, 0, 0, 0, 0, 0 }, {
{ 0.074245, 0.074245, 0.074245, 0.074245, -0.048197, 0.072167, -0.048197, 0.072167, -0.048859, 0.07006, -0.048859, 0.07006 }, matY(k, l) = vdYParts[l];
}; }
}
Eigen::MatrixXd matYinv = CalculatePseudoInverse(matY);
std::vector<double> vdRemaxWeights = HOARemaxWeights(m_iAmbisonicsTruncationOrder);
// Ambisonics outputs // Ambisonics outputs
for( size_t i=0; i<m_vpTargetOutputs.size(); i++ ) for( size_t i=0; i<m_vpTargetOutputs.size(); i++ )
...@@ -187,6 +127,7 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p ) ...@@ -187,6 +127,7 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
// Apply matrix as weighting gains of in/out patch bay (truncate higher orders if necessary) // Apply matrix as weighting gains of in/out patch bay (truncate higher orders if necessary)
for( int j=0; j < iMaxPossibleAmbisonicsChannelNumber; j++ ) for( int j=0; j < iMaxPossibleAmbisonicsChannelNumber; j++ )
{ {
int iCurrentOrder = floor(sqrt(j));
for( size_t k=0; k < pTargetOutput->GetPhysicalOutputChannels().size(); k++ ) for( size_t k=0; k < pTargetOutput->GetPhysicalOutputChannels().size(); k++ )
{ {
const VAVec3& v3LSPos( pTargetOutput->vpDevices[k]->vPos ); const VAVec3& v3LSPos( pTargetOutput->vpDevices[k]->vPos );
...@@ -198,7 +139,7 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p ) ...@@ -198,7 +139,7 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
// todo calculate gain @mko // todo calculate gain @mko
if ( j==0 && k==0 ) 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"); VA_WARN("AmbisonicsReproduction", "No dynamic HOA matrix calculation based on LS configuration available, using pre-calculated matrix for ITA VR lab");
double dGain = dYInv[j][k]; // TEMP use static gain from matrix double dGain = matYinv(i, j)*vdRemaxWeights[iCurrentOrder];
m_pDecoderMatrixPatchBay->ConnectChannels( 0, int( j ), 0, int( k ), dGain ); m_pDecoderMatrixPatchBay->ConnectChannels( 0, int( j ), 0, int( k ), dGain );
} }
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "../VAAudioReproductionModuleRegistry.h" #include "../VAAudioReproductionModuleRegistry.h"
#include "../../VACoreImpl.h" #include "../../VACoreImpl.h"
#include <ITASampleFrame.h> #include <ITASampleFrame.h>
#include <ITANumericUtils.h>
#include <ITAConstants.h>
#include "Eigen\Dense" #include "Eigen\Dense"
#include "Eigen\SVD" #include "Eigen\SVD"
#include "Eigen\Jacobi" #include "Eigen\Jacobi"
...@@ -51,6 +53,7 @@ private: ...@@ -51,6 +53,7 @@ private:
std::vector< const CVAHardwareOutput* > m_vpTargetOutputs; std::vector< const CVAHardwareOutput* > m_vpTargetOutputs;
ITAStreamPatchbay* m_pDecoderMatrixPatchBay; ITAStreamPatchbay* m_pDecoderMatrixPatchBay;
VAVec3 m_v3ReproductionCenterPos; VAVec3 m_v3ReproductionCenterPos;
const CVAHardwareOutput* m_pOutput;
}; };
#endif // ( VACORE_WITH_REPRODUCTION_AMBISONICS == 1 ) #endif // ( VACORE_WITH_REPRODUCTION_AMBISONICS == 1 )
......
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