Commit ca5353b5 authored by Daniel Filbert's avatar Daniel Filbert

fixing VBAP

parent e4a91fc7
......@@ -58,7 +58,7 @@ CVAVBAPFreeFieldAudioRenderer::CVAVBAPFreeFieldAudioRenderer( const CVAAudioRend
VA_EXCEPT2( INVALID_PARAMETER, "Unrecognized output '" + sOutput + "' in VBAP Freefield Renderer." );
m_vecCaveCenterPos.Set( 0.0f, 1.27f, 0.0f );
m_vecCaveCenterOrientYPR.Set(0.0f, 0.0f, 0.0f);
m_vecCaveCenterOrientYPR.Set( 0.0f, 0.0f, 0.0f );
/*
m_vecCaveCenterOrientYPR.SetToZeroVector();
*/
......@@ -68,7 +68,6 @@ CVAVBAPFreeFieldAudioRenderer::CVAVBAPFreeFieldAudioRenderer( const CVAAudioRend
{
const CVAHardwareDevice* pDevice( m_pOutput->vpDevices[ i ] );
CLoudspeaker oLS;
// oLS.pos.SetValues( pDevice->vPos.x, pDevice->vPos.y, pDevice->vPos.z );
oLS.pos.Set(pDevice->vPos.x, pDevice->vPos.y, pDevice->vPos.z);
oLS.iChannel = int( i );
oLS.iIdentifier = int( i );
......@@ -550,7 +549,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains3D( const VAVec3& v
{
// Calculate position of loudspeaker from virtual sound source
double positionValues[3];
// m_voLoudspeaker[i].pos.GetValues(positionValues);
positionValues[0] = m_voLoudspeaker[i].pos.x;
positionValues[1] = m_voLoudspeaker[i].pos.y;
positionValues[2] = m_voLoudspeaker[i].pos.z;
......@@ -568,18 +566,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains3D( const VAVec3& v
double *pInverse;
double Matrix[9];
double dInverseMatrix[9];
/*
double posLS1[3], posLS2[3], posLS3[3];
m_voLoudspeaker[oLoudSpeakerFromSoundSource[0].iIdentifier].pos.GetValues(posLS1);
m_voLoudspeaker[oLoudSpeakerFromSoundSource[1].iIdentifier].pos.GetValues(posLS2);
m_voLoudspeaker[oLoudSpeakerFromSoundSource[2].iIdentifier].pos.GetValues(posLS3);
VistaVector3D pos1 = m_voLoudspeaker[voLoudSpeakerFromSoundSource[0].iIdentifier].pos.GetNormalized();
VistaVector3D pos2 = m_voLoudspeaker[voLoudSpeakerFromSoundSource[1].iIdentifier].pos.GetNormalized();
VistaVector3D pos3 = m_voLoudspeaker[voLoudSpeakerFromSoundSource[2].iIdentifier].pos.GetNormalized();
*/
VAVec3 posLS1 = m_voLoudspeaker[voLoudSpeakerFromSoundSource[0].iIdentifier].pos - m_vecCaveCenterPos;
VAVec3 posLS2 = m_voLoudspeaker[voLoudSpeakerFromSoundSource[1].iIdentifier].pos - m_vecCaveCenterPos;
......@@ -589,16 +575,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains3D( const VAVec3& v
posLS2.Norm();
posLS3.Norm();
/*
pos1.GetValues(posLS1);
pos2.GetValues(posLS2);
pos3.GetValues(posLS3);
oLoudSpeakerFromSoundSource[0].pos.GetValues(posLS1);
oLoudSpeakerFromSoundSource[1].pos.GetValues(posLS2);
oLoudSpeakerFromSoundSource[2].pos.GetValues(posLS3);
*/
Matrix[0] = posLS1.x;
Matrix[1] = posLS1.y;
......@@ -612,19 +588,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains3D( const VAVec3& v
Matrix[7] = posLS3.y;
Matrix[8] = posLS3.z;
/*
Matrix[0] = posLS1[0];
Matrix[1] = posLS1[1];
Matrix[2] = posLS1[2];
Matrix[3] = posLS2[0];
Matrix[4] = posLS2[1];
Matrix[5] = posLS2[2];
Matrix[6] = posLS3[0];
Matrix[7] = posLS3[1];
Matrix[8] = posLS3[2];
*/
dInverseMatrix[0] = 0;
dInverseMatrix[1] = 0;
......@@ -643,11 +606,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains3D( const VAVec3& v
CalculateInverseMatrix3x3( pMatrix, pInverse );
// Get loudspeaker identifier
/* const int &LSID1 = pActiveSection->iLSIdentifier[0];
const int &LSID2 = pActiveSection->iLSIdentifier[1];
const int &LSID3 = pActiveSection->iLSIdentifier[2];
*/
const int &LSID1 = voLoudSpeakerFromSoundSource[0].iIdentifier;
const int &LSID2 = voLoudSpeakerFromSoundSource[1].iIdentifier;
const int &LSID3 = voLoudSpeakerFromSoundSource[2].iIdentifier;
......@@ -656,13 +614,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains3D( const VAVec3& v
vdLoudspeakerGains[LSID2] = vSoundSource.x * dInverseMatrix[1] + vSoundSource.y * dInverseMatrix[4] + vSoundSource.z * dInverseMatrix[7];
vdLoudspeakerGains[LSID3] = vSoundSource.x * dInverseMatrix[2] + vSoundSource.y * dInverseMatrix[5] + vSoundSource.z * dInverseMatrix[8];
/*
VAVec3 vSoundSourcePosFromListener = vSoundSource - m_vecCaveCenterPos;
vdLoudspeakerGains[LSID1] = vSoundSourcePosFromListener.x * dInverseMatrix[0] + vSoundSourcePosFromListener.y * dInverseMatrix[3] + vSoundSourcePosFromListener.z * dInverseMatrix[6];
vdLoudspeakerGains[LSID2] = vSoundSourcePosFromListener.x * dInverseMatrix[1] + vSoundSourcePosFromListener.y * dInverseMatrix[4] + vSoundSourcePosFromListener.z * dInverseMatrix[7];
vdLoudspeakerGains[LSID3] = vSoundSourcePosFromListener.x * dInverseMatrix[2] + vSoundSourcePosFromListener.y * dInverseMatrix[5] + vSoundSourcePosFromListener.z * dInverseMatrix[8];
*/
double dCorrection = sqrt(vdLoudspeakerGains[LSID1]*vdLoudspeakerGains[LSID1]+vdLoudspeakerGains[LSID2]*vdLoudspeakerGains[LSID2]+vdLoudspeakerGains[LSID3]*vdLoudspeakerGains[LSID3]);
vdLoudspeakerGains[LSID1]/=dCorrection;
......@@ -706,11 +657,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains2D( const VAVec3& v
int iLS1 = viMinIDs[ 0 ];
int iLS2 = viMinIDs[ 1 ];
/*
const VistaVector3D &posLS1 = m_voLoudspeaker[iLS1].pos;
const VistaVector3D &posLS2 = m_voLoudspeaker[iLS2].pos;
*/
const VAVec3 &posLS1 = m_voLoudspeaker[ iLS1 ].pos;
const VAVec3 &posLS2 = m_voLoudspeaker[ iLS2 ].pos;
......@@ -718,9 +664,6 @@ bool CVAVBAPFreeFieldAudioRenderer::CalculateLoudspeakerGains2D( const VAVec3& v
return false;
// Berechnung der Gains ber die Inverse
/*
double dDetA = ( -posLS1[ 2 ] * posLS2[ 0 ] ) - ( -posLS2[ 2 ] * posLS1[ 0 ] );
*/
double dDetA = (-posLS1.z * posLS2.x) - (-posLS2.z * posLS1.x);
if( dDetA == 0.0f )
......
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