Commit 4b2f0252 authored by henryjandrew's avatar henryjandrew

Updated wavefront GetOutput to use linear interpolation properly, and apply ITD diff changes

parent 876cbe4e
......@@ -87,7 +87,7 @@ void CVABinauralOutdoorWaveFront::GetOutput( ITASampleBuffer* pfLeftChannel, ITA
if (iNewDelay == iCurrentDelay) {
//Directly read from VDL -> IIR to L/R channels, no interp needed, as no change in delay, so no Doppler
VDL->SetOverlapSamples(iCursorID, itdDifference, 0); //no interp
int buffer_size = VDL->GetEffectiveReadLength(iCursorID, oConf.blockLength);
unsigned int buffer_size = VDL->GetEffectiveReadLength(iCursorID, oConf.blockLength);
VDL->Read(iCursorID, oConf.blockLength, tempBuffer.GetData()); //read VDL data to tempary buffer
oIIRFilterEngine.Process(tempBuffer.GetData(), tempBuffer.GetData(), buffer_size); //apply the IIR filter to the data taken from the VDL
......@@ -108,57 +108,27 @@ void CVABinauralOutdoorWaveFront::GetOutput( ITASampleBuffer* pfLeftChannel, ITA
VDL->SetOverlapSamples(iCursorID, interpolate_left + itdDifference, interpolate_right ); //set the overlap to be read from the VDL
int buffer_size = VDL->GetEffectiveReadLength(iCursorID,oConf.blockLength);
int interpolated_signal_size = oConf.blockLength + abs(itdDifference);
unsigned int buffer_size = VDL->GetEffectiveReadLength(iCursorID,oConf.blockLength);
unsigned int interpolated_signal_size = oConf.blockLength + abs(itdDifference);
//***************************************************Read data from VDL******************************************************
VDL->Read(iCursorID,oConf.blockLength,tempBuffer.GetData());
//*****************************************************Apply IIR Filter******************************************************
oIIRFilterEngine.Process(tempBuffer.GetData(), tempBuffer.GetData(), buffer_size); //apply the IIR filter to the data taken from the VDL
//*****************************************************Interpolate***********************************************************
int iAlgorithmLocalCopy = oConf.iSwitchingAlgorithm; //make internal varibles
int iDeltaDelay = iNewDelay - iCurrentDelay;
if ((iAlgorithmLocalCopy == LINEAR_INTERPOLATION) ||
(iAlgorithmLocalCopy == WINDOWED_SINC_INTERPOLATION) ||
(iAlgorithmLocalCopy == CUBIC_SPLINE_INTERPOLATION))
if (oConf.iSwitchingAlgorithm == LINEAR_INTERPOLATION )
{
float fResamplingFactor = 1 - iDeltaDelay / (float)oConf.blockLength; //work out re-sampling factor
if ((fResamplingFactor <= MIN_RESAMPLING_FACTOR) || (fResamplingFactor > MAX_RESAMPLING_FACTOR))
{
iAlgorithmLocalCopy = CROSSFADE;
}
m_pInterpolationRoutine->Interpolate(&tempBuffer, buffer_size, interpolate_left, &interpolatedSignal, interpolated_signal_size);
//output size decreased to be blocklength + left/right margin for ITD difference offset
}
switch (iAlgorithmLocalCopy)
{
case SWITCH:
{
else if(oConf.iSwitchingAlgorithm == SWITCH) {
//Directly switch from new to old delay: no interpolation skip to end
interpolatedSignal.write(tempBuffer.GetData(), interpolated_signal_size, interpolate_left, 0 );
break;
interpolatedSignal.write(tempBuffer, interpolated_signal_size, interpolate_left, 0);
}
case CROSSFADE:
{
//Think for this that we need to store the previous buffer (or atleast the read cursor) either here or in the VDL base (probably better in base)
VA_EXCEPT1("CROSSFADE not yet implememnted in VABinauralOutdoorWaveFront GetOutput");
break;
}
default: //Interpolate
{
m_pInterpolationRoutine->Interpolate(&tempBuffer, buffer_size, interpolate_left, &interpolatedSignal, interpolated_signal_size);
//output size decreased to be blocklength + left/right margin for ITD difference offset
break;
else {
VA_EXCEPT1("Unknown interpolation type forwarded to VABinaurlWaveFront, please use either 'LINEAR_INTERPOLATION', 'CROSSFADE', or 'SWITCH'.");
}
} // end case switch
//***************************************Apply ITD correction*************************************************
//write from the interpolated buffer to left/right channels with different offset depending on the ITD correction needed
if (itdDifference <= 0) { //adjust where data is read from the buffer depending on whether ITD diff is positive or negative
......
......@@ -40,10 +40,7 @@ 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
......
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