Commit fedaaee3 authored by Michael Kohnen's avatar Michael Kohnen
Browse files

Progress on Ambisonics rendering and reproduction

parent 0f1bc449
......@@ -227,8 +227,7 @@ private:
// Renderer
CVAAmbisonicsFreeFieldAudioRenderer::CVAAmbisonicsFreeFieldAudioRenderer(const CVAAudioRendererInitParams& oParams)
: ITADatasourceRealization(2, oParams.pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate, oParams.pCore->GetCoreConfig()->oAudioDriverConfig.iBuffersize)
, CVAObject(oParams.sClass + ":" + oParams.sID)
: CVAObject(oParams.sClass + ":" + oParams.sID)
, m_pCore(oParams.pCore)
, m_pCurSceneState(nullptr)
, m_bDumpListeners(false)
......@@ -240,20 +239,25 @@ CVAAmbisonicsFreeFieldAudioRenderer::CVAAmbisonicsFreeFieldAudioRenderer(const C
{
// read config
Init(*oParams.pConfig);
double dSampleRate = m_pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate;
int iBlockLength = m_pCore->GetCoreConfig()->oAudioDriverConfig.iBuffersize;
m_pdsOutput = new ITADatasourceRealization(m_iNumChannels, dSampleRate, iBlockLength);
m_pdsOutput->SetStreamEventHandler(this);
IVAPoolObjectFactory* pListenerFactory = new CVAAFFListenerPoolFactory(m_pCore, m_oDefaultListenerConf);
m_pListenerPool = IVAObjectPool::Create(16, 2, pListenerFactory, true);
IVAPoolObjectFactory* pSourceFactory = new CVAAFFSourcePoolFactory(m_oDefaultSourceConf);
m_pSourcePool = IVAObjectPool::Create(16, 2, pSourceFactory, true);
m_pSoundPathFactory = new CVAAFFSoundPathFactory(GetSampleRate(), GetBlocklength(), 128);
m_pSoundPathFactory = new CVAAFFSoundPathFactory(m_pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate, iBlockLength, 128);
m_pSoundPathPool = IVAObjectPool::Create(64, 8, m_pSoundPathFactory, true);
m_pUpdateMessagePool = IVAObjectPool::Create(2, 1, new CVAPoolObjectDefaultFactory<CVAAFFUpdateMessage>, true);
ctxAudio.m_sbTemp.Init(GetBlocklength(), true);
ctxAudio.m_sbTemp.Init(iBlockLength, true);
ctxAudio.m_iResetFlag = 0; // Normal operation mode
ctxAudio.m_iStatus = 0; // Stopped
......@@ -443,7 +447,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::UpdateScene(CVASceneState* pNewSceneSt
ITADatasource* CVAAmbisonicsFreeFieldAudioRenderer::GetOutputDatasource()
{
return this;
return m_pdsOutput;
}
void CVAAmbisonicsFreeFieldAudioRenderer::ManageSoundPaths(const CVASceneState* pCurScene,
......@@ -603,7 +607,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ManageSoundPaths(const CVASceneState*
return;
}
void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pStreamInfo)
void CVAAmbisonicsFreeFieldAudioRenderer::HandleProcessStream(ITADatasourceRealization*, const ITAStreamInfo* pStreamInfo)
{
if (ctxAudio.m_iStatus == 0)
{
......@@ -615,12 +619,12 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pSt
SyncInternalData();
std::vector<float*> pfOutputCh;
//for (int i = 0; i < m_iNumChannels; i++)
//{
// float* helper = GetWritePointer(i);
// fm_zero(helper, GetBlocklength());
// pfOutputCh.push_back(helper);
//}
for (int i = 0; i < m_iNumChannels; i++)
{
float* helper = m_pdsOutput->GetWritePointer(i);
fm_zero(helper, m_pdsOutput->GetBlocklength());
pfOutputCh.push_back(helper);
}
......@@ -734,7 +738,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pSt
for (int i = 0; i < m_iNumChannels; i++)
{
(*pPath->pListener->psfOutput)[i].MulAdd(ctxAudio.m_sbTemp, gains[i]*fSoundSourceGain, 0, 0, GetBlocklength());
(*pPath->pListener->psfOutput)[i].MulAdd(ctxAudio.m_sbTemp, gains[i] * fSoundSourceGain, 0, 0, m_pdsOutput->GetBlocklength());
}
spit++;
}
......@@ -743,8 +747,10 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pSt
if (!ctxAudio.m_lListeners.empty())
{
CVAAFFListener* pActiveListener = *(ctxAudio.m_lListeners.begin());
fm_copy(pfOutputCh[0], (*pActiveListener->psfOutput)[0].data(), m_uiBlocklength);
for (int i = 0; i < m_iNumChannels; i++)
{
fm_copy(pfOutputCh[i], (*pActiveListener->psfOutput)[i].data(), m_pdsOutput->GetBlocklength());
}
// Listener dumping
if (m_iDumpListenersFlag > 0)
{
......@@ -762,7 +768,7 @@ void CVAAmbisonicsFreeFieldAudioRenderer::ProcessStream(const ITAStreamInfo* pSt
}
}
IncrementWritePointer();
m_pdsOutput->IncrementWritePointer();
return;
}
......@@ -882,7 +888,7 @@ CVAAmbisonicsFreeFieldAudioRenderer::CVAAFFListener* CVAAmbisonicsFreeFieldAudio
pListener->pData->AddReference();
// Move to prerequest of pool?
pListener->psfOutput = new ITASampleFrame(2,
pListener->psfOutput = new ITASampleFrame(m_iNumChannels,
m_pCore->GetCoreConfig()->oAudioDriverConfig.iBuffersize,
true);
assert(pListener->pData);
......@@ -1460,7 +1466,7 @@ std::vector<double> CVAAmbisonicsFreeFieldAudioRenderer::dAssociateLegendre(int
std::vector<double> P;
P.resize((N+1)*(N+1));
P[0]=1.0*dNormalizeConst(0,0);
for (int n=0; n<N; n++)
for (int n=1; n<N; n++)
{
P[GetIndex(n,n)]=(-(2*n-1)*P[GetIndex((n-1),(n-1))]*sqrt(1-(mu*mu)))*dNormalizeConst(n,n);
......@@ -1485,10 +1491,7 @@ std::vector<double> CVAAmbisonicsFreeFieldAudioRenderer::dAssociateLegendre(int
int CVAAmbisonicsFreeFieldAudioRenderer::iFactorial(int in)
{
int out=in;
for (int i=0; i<in; i++)
out*=(in-i);
return out;
return factorial(in);
}
int CVAAmbisonicsFreeFieldAudioRenderer::GetIndex(int m, int n)
......
......@@ -47,6 +47,7 @@
#include <ITASampleFrame.h>
#include <ITAStringUtils.h>
// 3rdParty includes
#include <tbb/concurrent_queue.h>
#include <ITAVariableDelayLine.h>
......@@ -79,7 +80,7 @@ class CVAAFFSoundPathFactory;
* - Doppler shifts (source and listener movement in medium of finite speed of sound)
*
*/
class CVAAmbisonicsFreeFieldAudioRenderer : public IVAAudioRenderer, public ITADatasourceRealization, public CVAObject
class CVAAmbisonicsFreeFieldAudioRenderer : public IVAAudioRenderer, public ITADatasourceRealizationEventHandler, public CVAObject
{
public:
CVAAmbisonicsFreeFieldAudioRenderer(const CVAAudioRendererInitParams& oParams);
......@@ -123,8 +124,8 @@ public:
* filter parts and magnitudes of or Directivity. It also considers
* the effective auralisation mode.
*/
void ProcessStream(const ITAStreamInfo* pStreamInfo);
void HandleProcessStream(ITADatasourceRealization*, const ITAStreamInfo* pStreamInfo);
//! Returns the renderers output stream datasource
ITADatasource* GetOutputDatasource();
......@@ -281,7 +282,7 @@ protected:
};
private:
ITADatasourceRealization* m_pdsOutput; //!< Output datasource
const CVAAudioRendererInitParams m_oParams; //!< Create a const copy of the init params
CVACoreImpl* m_pCore; //!< Pointer to VACore
......
......@@ -48,7 +48,7 @@ CVAAmbisonicsBinauralMixdownReproduction::CVAAmbisonicsBinauralMixdownReproducti
{
CVAConfigInterpreter conf( *(m_oParams.pConfig) );
conf.ReqInteger( "AmbisonicsTruncationOrder", m_iAmbisonicsTruncationOrder ); // Sollte aus der Zahl der Eingangskanle berechnet werden
conf.ReqInteger( "TruncationOrder", m_iAmbisonicsTruncationOrder ); // Sollte aus der Zahl der Eingangskanle berechnet werden
conf.OptInteger( "HRIRFilterLength", m_iHRIRFilterLength, 128 );
conf.OptInteger( "TrackedListenerID", m_iListenerID, 1 );
......
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