Commit 7d528cb1 authored by henryjandrew's avatar henryjandrew

added a VDL to Outdoorsource, and an initial implementation of IIR filtering,...

added a VDL to Outdoorsource, and an initial implementation of IIR filtering, interpolation, and ITD correction to the WaveFront
parent fc0bc2d2
......@@ -117,9 +117,11 @@ void CVABinauralOutdoorNoiseRenderer::Init( const CVAStruct& oArgs )
m_oDefaultWaveFrontConf.blockLength = GetBlocklength();
m_oDefaultWaveFrontConf.sampleRate = GetSampleRate();
m_oDefaultWaveFrontConf.iFilterOrder = 4; //TODO: get these from the ini file as above
m_oDefaultWaveFrontConf.IR_length = 1024;
m_oDefaultWaveFrontConf.FilterDesignAlgorithm = CVABinauralOutdoorWaveFront::BURG;
conf.OptInteger("FilterOrder", m_oDefaultWaveFrontConf.iFilterOrder, 4);
conf.OptInteger("ImpulseResponseLength", m_oDefaultWaveFrontConf.IR_length, 1024);
conf.OptInteger("BufferSize", m_oDefaultWaveFrontConf.BufferSize, 1124);
m_oDefaultWaveFrontConf.FilterDesignAlgorithm = CVABinauralOutdoorWaveFront::BURG; //no other algorthms currently implemented
VAConfig::blockLength = GetBlocklength();
VAConfig::hrirLength = m_iHRIRFilterLength;
......@@ -148,10 +150,11 @@ void CVABinauralOutdoorNoiseRenderer::SetParameters(const CVAStruct& oInArgs)
const CVAStruct path = path_value;
//This is the unique string which identifies the current path for which data is being given (stored in "path")
std::string path_ID = path["path"]; //get path identifier from simulation engine. In future iterations, this will be generated within VA
int path_ID = path["ID"]; //get path identifier from simulation engine. In future iterations, this will be generated within VA
bool delete_path = path["delete"];
if (delete_path ) {
m_pClusterEngine->RemoveWaveFront(path_ID); //remove wavefront from the clustering engine
m_mPaths.erase(path_ID); //delete the sound path from the map
}
else {
......@@ -159,8 +162,18 @@ void CVABinauralOutdoorNoiseRenderer::SetParameters(const CVAStruct& oInArgs)
if (path_pos == m_mPaths.end()) { //if the path ID is not found, create a new path with this ID
CVABinauralOutdoorWaveFront* wave_front = dynamic_cast<CVABinauralOutdoorWaveFront*>(m_pWaveFrontPool->RequestObject()); //request a new path from the pool
m_mPaths.insert(std::pair<std::string, CVABinauralOutdoorWaveFront*>(path_ID, wave_front)); //put that path into the map with the label path_ID
m_mPaths.insert(std::pair<int, CVABinauralOutdoorWaveFront*>(path_ID, wave_front)); //put that path into the map with the label path_ID
//TODO: might need to add a reference to the new path here? *******************************************
m_mPaths[path_ID]->hasValidTrajectory = true; //TODO: check if this should be checked in some fn rather than just alway set
int path_source_ID = path["source"]; //get source ID from incoming data
m_mPaths[path_ID]->setSource(m_mSources[path_source_ID]); //set the source for this path
int path_receiver_ID = path["receiver"];
m_mPaths[path_ID]->setReceiver( m_mBinauralReceivers[path_receiver_ID] ); //set the sound receiver for this path
//m_pClusterEngine->AddWaveFront(path_ID, m_mPaths[path_ID]); //add new wave front to the clustering engine
}
CVAStructValue sMags = path["frequency_magnitudes"]; //
......@@ -175,16 +188,28 @@ void CVABinauralOutdoorNoiseRenderer::SetParameters(const CVAStruct& oInArgs)
Mags.SetMagnitude(i, pfMags[i]);
}
m_mPaths[path_ID]->setFilterCoefficients(Mags); //update the filter coefficients internal to the path based on the target frequency magnitudes
double delay = path["delay"];
m_mPaths[path_ID]->setDelay(delay); //update the delay for this path ********METHOD NOT YET IMPLEMENTED
m_mPaths[path_ID]->setDelay(delay);
m_mPaths[path_ID]->setMotion(); //update the motion of the path **********METHOD NOT YET IMPLEMENTED
//TODO: add extra "setters" for wave front delay, position/motion e.t.c
CVAStructValue position = path["position"]; //
num_values = position.GetDataSize() / sizeof(float); //currently only accepts third octave values, this is a safety check
if (num_values != 3)
VA_EXCEPT1("CVABinauralOutdoorNoiseRenderer: Expected a position vector with 3 components.");
void *pvposition = position.GetData();
const float* pfposition = (const float*)pvposition; //convert to float values
m_mPaths[path_ID]->v3PredictedPos.Set(pfposition[0], pfposition[1], pfposition[2]);
//m_mPaths[path_ID]->setMotion(); //update the motion of the path **********METHOD NOT YET IMPLEMENTED (dont think needed)
//TODO: add extra "setters" for wave front delay, position/motion e.t.c
if (path_pos == m_mPaths.end()) { //if the path ID is not found, create a new path with this ID
m_pClusterEngine->AddWaveFront(path_ID, m_mPaths[path_ID]); //add new wave front to the clustering engine
}
}
it++; //increment iterator for the next path
}
......
......@@ -68,7 +68,7 @@ private:
std::map< int, CVABinauralOutdoorSource* > m_mSources;
std::map< int, CVABinauralClusteringDirectionReceiver* > m_mBinauralReceivers;
std::map< std::string, CVABinauralOutdoorWaveFront* > m_mPaths; // All path of entire scene for all sources and receivers
std::map< int, CVABinauralOutdoorWaveFront* > m_mPaths; // All path of entire scene for all sources and receivers
//map containing all the paths, each accessed with a unique string key
CVABinauralClusteringEngine* m_pClusterEngine;
......
......@@ -2,8 +2,12 @@
CVABinauralOutdoorSource::CVABinauralOutdoorSource()
{
const int max_delay_samples = 1024; //TODO: take this number from ini file instead
pVDL = new CITASIMOVariableDelayLineBase(max_delay_samples);
}
CVABinauralOutdoorSource::~CVABinauralOutdoorSource()
{
delete pVDL;
}
#ifndef IW_VACORE_BINAURAL_OUTDOOR_SOURCE
#define IW_VACORE_BINAURAL_OUTDOOR_SOURCE
#include <ITASIMOVariableDelayLine.h>
#include <ITASIMOVariableDelayLineBase.h>
#include "../../../Motion/VASharedMotionModel.h"
#include "../../../Scene/VASoundSourceState.h"
......@@ -21,7 +21,7 @@ public:
CVASoundSourceDesc* pData;
CVASharedMotionModel* pMotionModel;
CITASIMOVariableDelayLine* pVDL;
CITASIMOVariableDelayLineBase* pVDL;
private:
};
......
......@@ -7,10 +7,16 @@
#include "../Clustering/WaveFront/VABinauralWaveFront.h"
#include <ITAThirdOctaveMagnitudeSpectrum.h>
#include "../Clustering/Receiver/VABinauralClusteringDirectionReceiver.h"
#include <ITAIIRFilterEngine.h>
#include "ITASIMOVariableDelayLineBase.h"
#include <ITAIIRCoefficients.h>
#include <ITAIIRUtils.h>
//#include <ITASIMOVariableDelayLine.h>
#include <ITAInterpolation.h>
......@@ -30,6 +36,16 @@ class CVABinauralOutdoorSource;
class CVABinauralOutdoorWaveFront : public IVABinauralWaveFront, public CVAPoolObject
{
public:
enum SwitchingAlgorithm
{
SWITCH = 0, //!< Hartes umschalten
CROSSFADE, //!< berblenden im Zeitbereich mittels Kreuzblende (Kosinus-Quadrat)
LINEAR_INTERPOLATION, //!< Stauchen und Strecken im Zeitbereich durch lineare Interpolation (Polynominterpolation der Ordnung 1)
WINDOWED_SINC_INTERPOLATION, //!< Stauchen und Strecken im Zeitbereich durch Interpolation mittels gefensterter si-Funktion
CUBIC_SPLINE_INTERPOLATION, //!< Stauchen und Strecken im Zeitbereich durch kubische Spline-Interpolation
};
struct Config
{
bool motionModelLogInput;
......@@ -46,6 +62,9 @@ public:
int iFilterOrder;
int IR_length;
int FilterDesignAlgorithm;
int BufferSize;
int iSwitchingAlgorithm;
};
......@@ -66,7 +85,7 @@ public:
CVASoundSourceDesc* pData;
CVASharedMotionModel* pMotionModel;
VAVec3 m_v3PredictedClusteringPos;
VAVec3 m_v3PredictedClusteringPos; //data of the position of the cluster this path belongs to
VAVec3 m_v3PredictedClusteringView;
VAVec3 m_v3PredictedClusteringUp;
......@@ -74,6 +93,11 @@ public:
VAVec3 predView; // @todo jst: appears to be useless in the context of clustering, confirm
VAVec3 predUp; // @todo jst: appears to be useless in the context of clustering, confirm
VAVec3 m_v3WaveFrontPos; //stores position data for the wave front - can be any point on the line the wave front travels to the source, as a normalisation happens later
VAVec3 v3ReceiverPos;
//VAVec3 m_v3WaveFrontView;
//VAVec3 m_v3WaveFrontUp;
CVABinauralOutdoorWaveFront( const CVABinauralOutdoorWaveFront::Config& conf );
~CVABinauralOutdoorWaveFront();
......@@ -87,10 +111,15 @@ public:
void setFilterCoefficients(const ITABase::CThirdOctaveGainMagnitudeSpectrum &oMags );
void setDelay( const float delay );
void setDelay( const int delay );
void setMotion();
void setSource(CVABinauralOutdoorSource* source);
void setReceiver(CVABinauralClusteringDirectionReceiver* sound_receiver);
virtual bool GetValidTrajectory() const
{
return hasValidTrajectory;
......@@ -114,13 +143,23 @@ public:
private:
double m_dCreationTimeStamp;
CITAVariableDelayLine* vdlChL; // Substitute with SIMO VDL (must be extended with a non-interpolating output)
CITAVariableDelayLine* vdlChR; // Remove, use separate SIMO VDL cursor for L/R channels
ITABase::CThirdOctaveGainMagnitudeSpectrum fMags;
ITADSP::CIIRCoefficients IIRFilterCoeffs;
CVABinauralOutdoorSource* sound_source;
CVABinauralClusteringDirectionReceiver* sound_receiver;
CITASIMOVariableDelayLineBase *VDL;
CITAIIRFilterEngine oIIRFilterEngine;
IITASampleInterpolationRoutine* m_pInterpolationRoutine; //!< Zeiger auf Interpolationsroutine
ITASampleBuffer tempBuffer;
ITASampleBuffer interpolatedSignal;
};
#endif // IW_VACORE_BINAURAL_OUTDOOR_WAVE_FRONT
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