Commit 8ce46f3e authored by Sebastian Riebeling's avatar Sebastian Riebeling

Modified BFormat Rotation. DecoderMatrix calculation modified, build one...

Modified BFormat Rotation. DecoderMatrix calculation modified, build one decoding matrix instead of multiple multiplications
parent 190890c1
......@@ -426,9 +426,6 @@ void calcRotationMatrix(Eigen::MatrixXd* m_orderMatrices, const int order, doubl
rotMat(2, 2) = cb * cy;
}
//Eigen::MatrixXd orderMatrices[5];
//Eigen::MatrixXd Rl = orderMatrices[1];
Eigen::MatrixXd zero(1, 1);
zero(0, 0) = 1;
......@@ -485,15 +482,16 @@ void calcRotationMatrix(Eigen::MatrixXd* m_orderMatrices, const int order, doubl
}
}
//Creates a 25x25 Matrix out of the RotationMatrices for every Order of Ambisonics
//Creates a InputChannel X InputChannel Matrix out of the RotationMatrices for every Order of Ambisonics
Eigen::MatrixXd buildRotationMatrix(Eigen::MatrixXd* m_orderMatrices, int m_iAmbisonicsTruncationOrder) {
int iCurrentOrder;
int boundary = pow(m_iAmbisonicsTruncationOrder + 1, 2);
//a rows and b columns
Eigen::MatrixXd matRotation(25, 25);
for (int a = 0; a < 25; a++) {
Eigen::MatrixXd matRotation(boundary, boundary);
for (int a = 0; a < boundary; a++) {
iCurrentOrder = floor(sqrt(a));
for (int b = 0; b < 25; b++) {
for (int b = 0; b < boundary; b++) {
// prevent to reach out of bounds for rotation matrices
if (iCurrentOrder > m_iAmbisonicsTruncationOrder) {
matRotation(a, b) = 0;
......@@ -549,10 +547,6 @@ void CVAAmbisonicsBinauralMixdownReproduction::UpdateScene(CVASceneState* pNewSt
return;
// Get the realworld position as position, view and up vector
//VAVec3 vListenerPos, vListenerView, vListenerUp;
//m_oParams.pCore->GetSoundReceiverRealWorldPositionOrientationVU(m_iListenerID, vListenerPos, vListenerView, vListenerUp);
// Motion model input
auto pMotionState = pNewState->GetReceiverState(m_iListenerID)->GetMotionState();
double dTime = pMotionState->GetModificationTime();
......@@ -601,101 +595,38 @@ void CVAAmbisonicsBinauralMixdownReproduction::UpdateScene(CVASceneState* pNewSt
double dRoll, dPitch, dYaw;
calculateYPRAnglesFromQuaternion(qRotatedViewToOrigin, dRoll, dPitch, dYaw);
//calculate a rotation matrix for every ambisonicsorder with calculated rotation angles roll ,pitch yaw
calcRotationMatrix(m_orderMatrices, m_iAmbisonicsTruncationOrder, dYaw, dPitch, dRoll);
//calcRotationMatrix(m_orderMatrices, m_iAmbisonicsTruncationOrder, 0, 0, ITAConstants::PI_D);
//To be deleted: display of matrices for every order
/*
Eigen::MatrixXd R0 = m_orderMatrices[0];
Eigen::MatrixXd R1 = m_orderMatrices[1];
Eigen::MatrixXd R2 = m_orderMatrices[2];
Eigen::MatrixXd R3 = m_orderMatrices[3];
Eigen::MatrixXd R4 = m_orderMatrices[4];
*/
/*
const int order1 = 3;
double matrix1[order1][order1];
for (int i = 0; i < order1; i++) {
for (int j = 0; j < order1; j++) {
matrix1[i][j] = R1(i, j);
}
}
const int order2 = 5;
double matrix2[order2][order2];
for (int i = 0; i < order2; i++) {
for (int j = 0; j < order2; j++) {
matrix2[i][j] = R2(i, j);
}
}
*/
/*
const int order3 = 7;
double matrix3[order3][order3];
for (int i = 0; i <= order3; i++) {
for (int j = 0; j <= order3; j++) {
matrix3[i][j] = R3(i, j);
}
}
const int order4 = 9;
double matrix4[order4][order4];
for (int i = 0; i < order4; i++) {
for (int j = 0; j < order4; j++) {
matrix4[i][j] = R4(i, j);
}
}
*/
//build ONE rotation matrix out of the several matrices for every ambisonics order
Eigen::MatrixXd matRotation = buildRotationMatrix(m_orderMatrices, m_iAmbisonicsTruncationOrder);
//To be deleted: only for testing purposes. Better display of 25x25 matrix (possible to see ind. values)
/*double matrix[25][25];
for (int i = 0; i < 25; i++) {
for (int j = 0; j < 25; j++) {
matrix[i][j] = matRotation(i, j);
}
//Init diag matrix for weights
Eigen::MatrixXd matDiagRemax(GetNumInputChannels(),GetNumInputChannels());
matDiagRemax.diagonal();
matDiagRemax.setZero();
//add weights to diagonal
Eigen::VectorXd vdRemaxWeights;
for (int i = 0; i < GetNumInputChannels(); i++) {
matDiagRemax(i,i) = m_vdRemaxWeights[floor(sqrt(i))];
}
*/
/*Eigen::MatrixXd matYinvRot = matRotation * m_matYinv;
double debugYinvRot[25][25];
for (int i = 0; i < 25; i++) {
for (int j = 0; j < 25; j++) {
debugYinvRot[i][j] = matYinvRot(i, j);
}
}
double debugYinv[25][25];
for (int i = 0; i < 25; i++) {
for (int j = 0; j < 25; j++) {
debugYinv[i][j] = m_matYinv(i, j); //matrix[zeilen][spalten]
}
}
*/
//Calculate the new decoding matrix with: Rotation, weights and the old decoding matrix
Eigen::MatrixXd matDecoder = m_matYinv.transpose() * matDiagRemax * matRotation;
/*Eigen::DiagonalMatrix diag(5);
Eigen::MatrixXd matDiagRemax(GetNumInputChannels,GetNumInputChannels);
//matDiagRemax.diagonal()
Eigen::MatrixXd matDecoder = m_matYinv.transpose()*
*/
int m, n;
int iCurrentOrder;
double dGain = 0;
//set gains to the channels according to the decoding matrix
for (int i = 0; i < GetNumInputChannels(); i++) {
iCurrentOrder = floor(sqrt(i));
for (int j = 0; j < GetNumVirtualLoudspeaker(); j++)
{
for (int k = 0; k < 25; k++) {
SHLinear2DegreeOrder(k, m, n);
dGain += m_matYinv(k, j) * matRotation(i, k) * m_vdRemaxWeights[n];
}
m_pDecoderMatrixPatchBay->ConnectChannels(0, i, 0, j, dGain);
dGain = 0;
dGain = matDecoder(j, i);
m_pDecoderMatrixPatchBay->ConnectChannels(0, i, 0, j, dGain);
}
}
}
else if ((m_sRotationMode == "ViewUp") || (m_sRotationMode == "Quaternion") || !m_bBFormatIsInit) {
......
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