Commit 0b3668e9 authored by Michael Kohnen's avatar Michael Kohnen
Browse files

Completed Ambisonics

parent 89ebef46
......@@ -611,12 +611,13 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pSt
// Schallpfade abgleichen
SyncInternalData();
std::list<float*> pfOutputCh;
std::vector<float*> pfOutputCh;
for (int i = 0; i < m_iNumChannels; i++)
{
float* helper = GetWritePointer(i);
fm_zero(helper, GetBlocklength());
pfOutputCh.push_back(helper);
fm_zero((pfOutputCh[i]), GetBlocklength());
}
......@@ -720,12 +721,17 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pSt
CVASoundSourceDesc* pSourceData = pPath->pSource->pData;
const ITASampleBuffer* psbInput = pSourceData->pSignalSourceInputBuf;
assert(psbInput); // Knallt es hier, dann ist die Eingabequelle noch nicht gesetzt
assert(pSourceData->iID >= 0); // Knallt es hier, dann wurde dem SoundPath unterm hintern die Quelle entzogen! -> Problem mit Referenzierung und Reset?
assert(pSourceData->iID >= 0); // Knallt es hier, dann wurde dem SoundPath unterm Hintern die Quelle entzogen! -> Problem mit Referenzierung und Reset?
pPath->pThirdOctaveFilterBank->Process(psbInput->data(), ctxAudio.m_sbTemp.data());
pPath->pVariableDelayLineCh->Process(&(ctxAudio.m_sbTemp), &(ctxAudio.m_sbTemp));
// Hier Schleife ber Outputs
std::vector<double> gains = vdRealvalued_basefunctions( (90-pPath->oRelations.dElevationL2S), pPath->oRelations.dAzimuthL2S, m_iMaxOrder);
for (int i = 0; i < m_iNumChannels; i++)
{
(*pPath->pListener->psfOutput)[i].MulAdd(ctxAudio.m_sbTemp, gains[i], 0, 0, GetBlocklength());
}
spit++;
}
......@@ -733,7 +739,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pSt
if (!ctxAudio.m_lListeners.empty())
{
CVAAFFListener* pActiveListener = *(ctxAudio.m_lListeners.begin());
fm_copy(pfOutputCh, (*pActiveListener->psfOutput)[0].data(), m_uiBlocklength);
fm_copy(pfOutputCh[0], (*pActiveListener->psfOutput)[0].data(), m_uiBlocklength);
// Listener dumping
if (m_iDumpListenersFlag > 0)
......@@ -1112,17 +1118,18 @@ CVAAFFSoundPath::CVAAFFSoundPath(double dSamplerate, int iBlocklength, int iDirF
float fReserverdMaxDelaySamples = (float)(3 * dSamplerate); // 3 Sekunden ~ 1km Entfernung
m_iDefaultVDLSwitchingAlgorithm = CVAVariableDelayLine::LINEAR_INTERPOLATION;
pVariableDelayLineChL = new CVAVariableDelayLine(dSamplerate, iBlocklength, fReserverdMaxDelaySamples, m_iDefaultVDLSwitchingAlgorithm);
pVariableDelayLineChR = new CVAVariableDelayLine(dSamplerate, iBlocklength, fReserverdMaxDelaySamples, m_iDefaultVDLSwitchingAlgorithm);
pFIRConvolverChL = new DSMBCConvolver(iBlocklength, iHRIRFilterLength);
pFIRConvolverChL->setFilterExchangeMode(DSMBCConvolver::CROSSFADE_COSINE_SQUARE);
pFIRConvolverChL->setFilterCrossfadeLength((std::min)(iBlocklength, 32));
pFIRConvolverChL->setGain(0.0f, true);
DSMBCFilter* pHRIRFilterChL = pFIRConvolverChL->requestFilter();
pVariableDelayLineCh = new CVAVariableDelayLine(dSamplerate, iBlocklength, fReserverdMaxDelaySamples, m_iDefaultVDLSwitchingAlgorithm);
//pVariableDelayLineChR = new CVAVariableDelayLine(dSamplerate, iBlocklength, fReserverdMaxDelaySamples, m_iDefaultVDLSwitchingAlgorithm);
/*pFIRConvolverCh = new DSMBCConvolver(iBlocklength, iHRIRFilterLength);
pFIRConvolverCh->setFilterExchangeMode(DSMBCConvolver::CROSSFADE_COSINE_SQUARE);
pFIRConvolverCh->setFilterCrossfadeLength((std::min)(iBlocklength, 32));
pFIRConvolverCh->setGain(0.0f, true);
DSMBCFilter* pHRIRFilterChL = pFIRConvolverCh->requestFilter();
pHRIRFilterChL->identity();
pFIRConvolverChL->exchangeFilter(pHRIRFilterChL);
pFIRConvolverCh->exchangeFilter(pHRIRFilterCh);
pFIRConvolverChR = new DSMBCConvolver(iBlocklength, iHRIRFilterLength);
pFIRConvolverChR->setFilterExchangeMode(DSMBCConvolver::CROSSFADE_COSINE_SQUARE);
pFIRConvolverChR->setFilterCrossfadeLength((std::min)(iBlocklength, 32));
......@@ -1130,21 +1137,19 @@ CVAAFFSoundPath::CVAAFFSoundPath(double dSamplerate, int iBlocklength, int iDirF
DSMBCFilter* pHRIRFilterChR = pFIRConvolverChR->requestFilter();
pHRIRFilterChR->identity();
pFIRConvolverChL->exchangeFilter(pHRIRFilterChR);
// Auto-release filter after it is not used anymore
pFIRConvolverChL->releaseFilter(pHRIRFilterChL);
pFIRConvolverChR->releaseFilter(pHRIRFilterChR);
m_sfHRIRTemp.init(2, iHRIRFilterLength, false);
*/
}
CVAAFFSoundPath::~CVAAFFSoundPath()
{
delete pThirdOctaveFilterBank;
delete pVariableDelayLine;
delete pFIRConvolverChL;
delete pFIRConvolverChR;
delete pVariableDelayLineCh;
}
void CVAAFFSoundPath::UpdateMetrics()
......
......@@ -99,6 +99,8 @@ void CVAAmbisonicsReproduction::SetInputDatasource( ITADatasource* p )
// todo calculate gain @mko
double dGain = dYInv[j][k]; // TEMP use static gain from matrix
m_pDecoderMatrixPatchBay->ConnectChannels( 0, int( j ), 0, int( k ), dGain );
......
......@@ -3,13 +3,21 @@ function [ s ] = loadMotion( filename )
A = fscanf(fid, '%f');
fclose(fid);
n = length(A)/4;
A = reshape(A,4,n);
n = round(length(A)/17);
A = reshape(A,17,n);
s = struct;
s.t = A(1,:);
s.x = A(2,:);
s.y = A(3,:);
s.z = A(4,:);
s.xVelo = A(5,:);
s.yVelo = A(6,:);
s.zVelo = A(7,:);
s.yaw = A(14,:);
s.pitch = A(15,:);
s.roll = A(16,:);
end
close all;
%m1 = loadMotion('motion_dreick.dat');
m1 = loadMotion('motion.dat');
m1 = loadMotion('test.dat');
n = length(m1.t);
v = zeros(1,n);
......
close all;
%fid = fopen('..\Release_x64\path.dat', 'r');
fid = fopen('path.dat', 'r');
fid = fopen('test.dat', 'r');
A = fscanf(fid, '%f');
fclose(fid);
n = length(A)/4;
A = reshape(A,4,n);
n = length(A)/17;
A = reshape(A,17,n);
% Ersten Werte wegwerfen
%A = A(:,30:end)
n = size(A,2)
......
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