Commit aa7115c6 authored by michael.kohnen's avatar michael.kohnen
Browse files

finalized Ambisonics encoding, implemented static

version of binaural mixdown (decoder matrix has to be pre-calculated)
parent a73a9f06
...@@ -7,129 +7,129 @@ ...@@ -7,129 +7,129 @@
Description = Equiangular placed loudspeaker Description = Equiangular placed loudspeaker
Enabled = true Enabled = true
Devices = LS1, LS1, LS2, LS3, LS4, LS5, LS6, LS7, LS8, LS9, LS10, LS11, LS12, LS13, LS14, LS15, LS16, LS17, LS18, LS19, LS20, LS21, LS22, LS23, LS24, LS25 Devices = LS1, LS2, LS3, LS4, LS5, LS6, LS7, LS8, LS9, LS10, LS11, LS12, LS13, LS14, LS15, LS16, LS17, LS18, LS19, LS20, LS21, LS22, LS23, LS24, LS25
[OutputDevice:LS1] [OutputDevice:LS1]
Type = LS Type = LS
Channels = 1 Channels = 1
Position = 6.1232e-17,0,1 Position = 0,1,-6.1232e-17
[OutputDevice:LS2] [OutputDevice:LS2]
Type = LS Type = LS
Channels = 2 Channels = 2
Position = 0.89694,0,-0.44216 Position = 0,-0.44216,-0.89694
[OutputDevice:LS3] [OutputDevice:LS3]
Type = LS Type = LS
Channels = 3 Channels = 3
Position = -0.92378,0.32687,0.19947 Position = -0.32687,0.19947,0.92378
[OutputDevice:LS4] [OutputDevice:LS4]
Type = LS Type = LS
Channels = 4 Channels = 4
Position = 0.14369,-0.98721,0.069029 Position = 0.98721,0.069029,-0.14369
[OutputDevice:LS5] [OutputDevice:LS5]
Type = LS Type = LS
Channels = 5 Channels = 5
Position = -0.43833,-0.77885,0.44862 Position = 0.77885,0.44862,0.43833
[OutputDevice:LS6] [OutputDevice:LS6]
Type = LS Type = LS
Channels = 6 Channels = 6
Position = -0.73358,0.48015,-0.48095 Position = -0.48015,-0.48095,0.73358
[OutputDevice:LS7] [OutputDevice:LS7]
Type = LS Type = LS
Channels = 7 Channels = 7
Position = 0.3816,-0.17993,-0.90665 Position = 0.17993,-0.90665,-0.3816
[OutputDevice:LS8] [OutputDevice:LS8]
Type = LS Type = LS
Channels = 8 Channels = 8
Position = -0.25516,0.23215,-0.93862 Position = -0.23215,-0.93862,0.25516
[OutputDevice:LS9] [OutputDevice:LS9]
Type = LS Type = LS
Channels = 9 Channels = 9
Position = 0.16918,-0.65248,0.73868 Position = 0.65248,0.73868,-0.16918
[OutputDevice:LS10] [OutputDevice:LS10]
Type = LS Type = LS
Channels = 10 Channels = 10
Position = 0.78132,-0.60413,0.15673 Position = 0.60413,0.15673,-0.78132
[OutputDevice:LS11] [OutputDevice:LS11]
Type = LS Type = LS
Channels = 11 Channels = 11
Position = 0.96564,0.11457,0.23328 Position = -0.11457,0.23328,-0.96564
[OutputDevice:LS12] [OutputDevice:LS12]
Type = LS Type = LS
Channels = 12 Channels = 12
Position = -0.92653,-0.35422,0.12681 Position = 0.35422,0.12681,0.92653
[OutputDevice:LS13] [OutputDevice:LS13]
Type = LS Type = LS
Channels = 13 Channels = 13
Position = -0.52552,-0.80741,-0.26818 Position = 0.80741,-0.26818,0.52552
[OutputDevice:LS14] [OutputDevice:LS14]
Type = LS Type = LS
Channels = 14 Channels = 14
Position = 0.116,0.95081,0.28724 Position = -0.95081,0.28724,-0.116
[OutputDevice:LS15] [OutputDevice:LS15]
Type = LS Type = LS
Channels = 15 Channels = 15
Position = 0.63385,-0.16237,0.75622 Position = 0.16237,0.75622,-0.63385
[OutputDevice:LS16] [OutputDevice:LS16]
Type = LS Type = LS
Channels = 16 Channels = 16
Position = -0.14052,-0.59325,-0.79266 Position = 0.59325,-0.79266,0.14052
[OutputDevice:LS17] [OutputDevice:LS17]
Type = LS Type = LS
Channels = 17 Channels = 17
Position = -0.65328,-0.10299,0.75008 Position = 0.10299,0.75008,0.65328
[OutputDevice:LS18] [OutputDevice:LS18]
Type = LS Type = LS
Channels = 18 Channels = 18
Position = -0.51895,0.85196,0.069728 Position = -0.85196,0.069728,0.51895
[OutputDevice:LS19] [OutputDevice:LS19]
Type = LS Type = LS
Channels = 19 Channels = 19
Position = 0.42595,0.48217,-0.76556 Position = -0.48217,-0.76556,-0.42595
[OutputDevice:LS20] [OutputDevice:LS20]
Type = LS Type = LS
Channels = 20 Channels = 20
Position = 0.49917,-0.72077,-0.48095 Position = 0.72077,-0.48095,-0.49917
[OutputDevice:LS21] [OutputDevice:LS21]
Type = LS Type = LS
Channels = 21 Channels = 21
Position = -0.33045,0.57288,0.75007 Position = -0.57288,0.75007,0.33045
[OutputDevice:LS22] [OutputDevice:LS22]
Type = LS Type = LS
Channels = 22 Channels = 22
Position = -0.022394,0.89509,-0.44532 Position = -0.89509,-0.44532,0.022394
[OutputDevice:LS23] [OutputDevice:LS23]
Type = LS Type = LS
Channels = 23 Channels = 23
Position = 0.69335,0.71173,-0.11269 Position = -0.71173,-0.11269,-0.69335
[OutputDevice:LS24] [OutputDevice:LS24]
Type = LS Type = LS
Channels = 24 Channels = 24
Position = -0.76088,-0.21394,-0.61262 Position = 0.21394,-0.61262,0.76088
[OutputDevice:LS25] [OutputDevice:LS25]
Type = LS Type = LS
Channels = 25 Channels = 25
Position = 0.52268,0.53917,0.66038 Position = -0.53917,0.66038,-0.52268
\ No newline at end of file \ No newline at end of file
...@@ -734,7 +734,8 @@ void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream(ITADatasourceReali ...@@ -734,7 +734,8 @@ void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream(ITADatasourceReali
pPath->pVariableDelayLineCh->Process(&(ctxAudio.m_sbTemp), &(ctxAudio.m_sbTemp)); pPath->pVariableDelayLineCh->Process(&(ctxAudio.m_sbTemp), &(ctxAudio.m_sbTemp));
std::vector<double> gains = vdRealvalued_basefunctions( (90-pPath->oRelations.dElevationL2S), pPath->oRelations.dAzimuthL2S, m_iMaxOrder); //std::vector<double> gains = vdRealvalued_basefunctions( (90-pPath->oRelations.dElevationL2S), pPath->oRelations.dAzimuthL2S, m_iMaxOrder);
std::vector<double> gains = SHRealvaluedBasefunctions((90 - pPath->oRelations.dElevationL2S) / 180 * 3.14159265359, pPath->oRelations.dAzimuthL2S / 180 * 3.14159265359, m_iMaxOrder);
for (int i = 0; i < m_iNumChannels; i++) for (int i = 0; i < m_iNumChannels; i++)
{ {
...@@ -1321,8 +1322,10 @@ std::vector<double> CVAAmbisonicsFreeFieldAudioRenderer::vdRealvalued_basefuncti ...@@ -1321,8 +1322,10 @@ std::vector<double> CVAAmbisonicsFreeFieldAudioRenderer::vdRealvalued_basefuncti
double CVAAmbisonicsFreeFieldAudioRenderer::dNormalizeConst(int m, int n) double CVAAmbisonicsFreeFieldAudioRenderer::dNormalizeConst(int m, int n)
{ {
double Res = 1; double Res = 1;
if (m%2==1) if (m % 2 == 1)
Res=-1; {
Res = -1;
}
return Res * sqrt((2*n+1) * (2-iKronecker(m)) * factorial(n-m) / (4*3.141592565359*factorial(n+m)) ); return Res * sqrt((2*n+1) * (2-iKronecker(m)) * factorial(n-m) / (4*3.141592565359*factorial(n+m)) );
...@@ -1345,23 +1348,12 @@ std::vector<double> CVAAmbisonicsFreeFieldAudioRenderer::dAssociateLegendre(int ...@@ -1345,23 +1348,12 @@ std::vector<double> CVAAmbisonicsFreeFieldAudioRenderer::dAssociateLegendre(int
P[0] = 1.0;// *dNormalizeConst(0, 0); P[0] = 1.0;// *dNormalizeConst(0, 0);
for (int n=1; n<=N; n++) for (int n=1; n<=N; n++)
{ {
dN = dNormalizeConst(n, n);
P[GetIndex(n, n)] = (-(2 * n - 1)*P[GetIndex((n - 1), (n - 1))] * sqrt(1 - (mu*mu)));// *dN; P[GetIndex(n, n)] = (-(2 * n - 1)*P[GetIndex((n - 1), (n - 1))] * sqrt(1 - (mu*mu)));// *dN;
P[GetIndex(n - 1, n)] = ( 2 * n - 1)*mu*P[GetIndex(n - 1, n - 1)];// *dN; //m-ter Grad
if(n>=1) for (int m=0; m<(n-1); m++)
{ {
dN = dNormalizeConst(n - 1, n);
P[GetIndex(n - 1, n)] = (-((2 * n) - 1)*mu*P[GetIndex(n - 1, n - 1)]);// *dN; //m-ter Grad
if(n>=2)
{
for (int m=0; m<(n-2); m++)
{
dN = dNormalizeConst(m, n);
P[GetIndex(m, n)] = 1 / (n - m)*(2 * n - 1)*mu*P[GetIndex(m, n - 1)] - (n + m - 1)*P[GetIndex(m, n - 2)];// *dN; P[GetIndex(m, n)] = 1 / (n - m)*(2 * n - 1)*mu*P[GetIndex(m, n - 1)] - (n + m - 1)*P[GetIndex(m, n - 2)];// *dN;
} }
}
}
for (int m=1; m<=n; m++) for (int m=1; m<=n; m++)
{ {
P[GetIndex(-m, n)] = P[GetIndex(m, n)]; P[GetIndex(-m, n)] = P[GetIndex(m, n)];
......
...@@ -83,9 +83,24 @@ CVAAmbisonicsBinauralMixdownReproduction::CVAAmbisonicsBinauralMixdownReproducti ...@@ -83,9 +83,24 @@ CVAAmbisonicsBinauralMixdownReproduction::CVAAmbisonicsBinauralMixdownReproducti
m_pDecoderMatrixPatchBay->AddOutput( GetNumVirtualLoudspeaker() ); m_pDecoderMatrixPatchBay->AddOutput( GetNumVirtualLoudspeaker() );
m_pdsStreamFilter = new CMixdownStreamFilter( GetNumVirtualLoudspeaker(), dSampleRate, iBlockLength, m_iHRIRFilterLength ); m_pdsStreamFilter = new CMixdownStreamFilter( GetNumVirtualLoudspeaker(), dSampleRate, iBlockLength, m_iHRIRFilterLength );
m_pdsStreamFilter->pdsInput = m_pDecoderMatrixPatchBay->GetOutputDatasource( 0 ); m_pdsStreamFilter->pdsInput = m_pDecoderMatrixPatchBay->GetOutputDatasource( 0 );
double dYInv[9][25] =
{
{ 0.141479, 0.141920, 0.141646, 0.141830, 0.142275, 0.141479, 0.141526, 0.141477, 0.141646, 0.141477, 0.141994, 0.142275, 0.142275, 0.141994, 0.141526, 0.141646, 0.141830, 0.141526, 0.141994, 0.141479, 0.141477, 0.141920, 0.142466, 0.141830, 0.141920 },
{ 0.005941, 0.000089, 0.086866, -0.289171, -0.218760, 0.132279, -0.048748, 0.071201, -0.185809, -0.181762, 0.034672, -0.097372, -0.227303, 0.268540, -0.043764, -0.167073, -0.026226, 0.231909, 0.143544, -0.214299, 0.160602, 0.253240, 0.208520, -0.056470, 0.159354 },
{ 0.290269, -0.120293, 0.057773, 0.017307, 0.127976, -0.149033, -0.246478, -0.271526, 0.204262, 0.037630, 0.059254, 0.035368, -0.077298, 0.084189, 0.205663, -0.219915, 0.224294, 0.018744, -0.214181, -0.129190, 0.225973, -0.132183, -0.033016, -0.182721, 0.187134 },
{ -0.010309, 0.259113, -0.259466, 0.048463, -0.121716, -0.211398, 0.104138, -0.083419, 0.044248, 0.226498, 0.275812, -0.261374, -0.146311, 0.039797, 0.172511, -0.043928, -0.187809, -0.140852, 0.119610, 0.147593, -0.094330, -0.002682, 0.203135, -0.222917, 0.145594 },
{ 0.003282, -0.006696, -0.269060, -0.131720, 0.296452, -0.310102, -0.063386, -0.049882, -0.103034, -0.428107, 0.094691, 0.284039, 0.372584, 0.114170, -0.092901, 0.073076, 0.056890, -0.381878, 0.184781, -0.325510, -0.157803, -0.006838, 0.444594, 0.142130, 0.260228 },
{ 0.006189, -0.003088, 0.059091, -0.061678, -0.317678, -0.218363, 0.141425, -0.209619, -0.439036, -0.085531, 0.030327, -0.038565, 0.201335, 0.253543, -0.105321, 0.428546, -0.068044, 0.051366, -0.347849, 0.314950, 0.398489, -0.373260, -0.072262, 0.118783, 0.336251 },
{ 0.519905, -0.128956, -0.222463, -0.253086, -0.095566, -0.071242, 0.363030, 0.423903, 0.166847, -0.253144, -0.231166, -0.242859, -0.197860, -0.179531, 0.179474, 0.223870, 0.180918, -0.239684, 0.189199, -0.092858, 0.186994, -0.092435, -0.250168, 0.034298, 0.082579 },
{ -0.009086, -0.352444, -0.165782, 0.007717, -0.177053, 0.316863, -0.292659, 0.226190, 0.099659, 0.096699, 0.185697, -0.105388, 0.131534, 0.030299, 0.408122, 0.113469, -0.438948, -0.030252, -0.278323, -0.207655, -0.222219, 0.016649, -0.070396, 0.420575, 0.296734 },
{ -0.012261, 0.367459, 0.351366, -0.428608, -0.189546, 0.145810, 0.047338, -0.002382, -0.187556, 0.115177, 0.413844, 0.336094, -0.171487, -0.398253, 0.158751, -0.155985, 0.188937, -0.192006, -0.025891, -0.117003, -0.096159, -0.357402, -0.011634, 0.237909, -0.016513 },
};
//if (m_iAmbisonicsTruncationOrder == 3) //if (m_iAmbisonicsTruncationOrder == 3)
//{ //{
double dYInv[16][12] = /* { double dYInv[16][12] =
{ {
{ 0.1935, 0.1935, 0.1935, 0.1935, 0.2222, 0.2222, 0.2222, 0.2222, 0.2386, 0.2386, 0.2386, 0.2386 }, { 0.1935, 0.1935, 0.1935, 0.1935, 0.2222, 0.2222, 0.2222, 0.2222, 0.2386, 0.2386, 0.2386, 0.2386 },
{ 0.5226, -0.5226, -0.5226, 0.5226, -0.0000, -0.6052, 0.0000, 0.6052, -0.0000, -0.6203, 0.0000, 0.6203 }, { 0.5226, -0.5226, -0.5226, 0.5226, -0.0000, -0.6052, 0.0000, 0.6052, -0.0000, -0.6203, 0.0000, 0.6203 },
...@@ -104,7 +119,7 @@ CVAAmbisonicsBinauralMixdownReproduction::CVAAmbisonicsBinauralMixdownReproducti ...@@ -104,7 +119,7 @@ CVAAmbisonicsBinauralMixdownReproduction::CVAAmbisonicsBinauralMixdownReproducti
{ -0.0000, 0.0000, 0.0000, 0.0000, 1.4519, -1.4519, 1.4519, -1.4519, -1.4043, 1.4043, -1.4043, 1.4043 }, { -0.0000, 0.0000, 0.0000, 0.0000, 1.4519, -1.4519, 1.4519, -1.4519, -1.4043, 1.4043, -1.4043, 1.4043 },
{ -1.5412, -1.5412, 1.5412, 1.5412, 1.1505, 0.0000, -1.1505, -0.0000, 1.3099, -0.0000, -1.3099, 0.0000 }, { -1.5412, -1.5412, 1.5412, 1.5412, 1.1505, 0.0000, -1.1505, -0.0000, 1.3099, -0.0000, -1.3099, 0.0000 },
}; };
/* } }
else if (m_iAmbisonicsTruncationOrder == 2) else if (m_iAmbisonicsTruncationOrder == 2)
{ {
double dYInv[9][12] = double dYInv[9][12] =
......
Supports Markdown
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