Applying new usage of interpolation interface

parent 178b2a13
......@@ -57,11 +57,11 @@ public:
* and right-side samples can be retrieved via the function GetOverlapSamples().
*
* \param pInput In buffer pointer
* \param iInputLength Length of input samples
* \param iInputLength Length of input samples to run interpolation on (not including overlapping samples required for algorithm, this is given by iInputStartOffset)
* \param iInputStartOffset Offset on input buffer (usually = left-side overlap samples)
* \param pOutput Out buffer pointer
* \param iOutputLength Length of requested output sample
* \param iOutputOffset Offset in output buffer
* \param iOutputOffset Offset where to write into output buffer
*
* \return True, if interpolation algorithm could be executed
*
......
......@@ -132,12 +132,9 @@ bool CITASampleCubicSplineInterpolation::Interpolate( const ITASampleBuffer* pIn
assert( iOutputLength > 0 );
assert( pOutput->length() >= iOutputLength + iOutputOffset );
// Samples, die aufgeholt (>0) bzw. abgebremst (<0) werden mssen
int iDeltaDelay = ( iInputLength - iInputStartOffset ) - iOutputLength;
// Resamplingfaktor
float r = 1 + iDeltaDelay / ( float ) iOutputLength;
float r = iInputLength / ( float ) iOutputLength;
// --= Resampling =--
......@@ -146,19 +143,18 @@ bool CITASampleCubicSplineInterpolation::Interpolate( const ITASampleBuffer* pIn
float* pOutputData = pOutput->data();
// Return value
std::vector< float > vfInputSecondDerivatives( iInputLength );
spline_cubic_set_equidistant( iInputLength, pInputData, vfInputSecondDerivatives ); // Natural spline interpolation
std::vector< float > vfInputSecondDerivatives( iInputLength + iInputStartOffset );
spline_cubic_set_equidistant( iInputLength + iInputStartOffset, pInputData, vfInputSecondDerivatives ); // Natural spline interpolation
for( int i = 0; i < iOutputLength; i++ )
{
// Position in der Eingabe berechnen (relativ zum Anfang mit Offset)
float fXInput = ( i + 1 )*r - 1;
if( i == iOutputLength - 1 )
assert( iOutputLength + iDeltaDelay == iInputLength - iInputStartOffset );
// Position in the input buffer
float fXInput = ( i + 1 )*r + iInputStartOffset - 1;
// First item (index): fXInput = r - 1
// Last item (index): fXInput = iInputLength + iInputStartOffset - 1
// Spline-Segment auswerten
float fYOutput = spline_cubic_val_equidistant( fXInput + iInputStartOffset, pInputData, vfInputSecondDerivatives );
// Spline segment evaluation at given position
float fYOutput = spline_cubic_val_equidistant( fXInput, pInputData, vfInputSecondDerivatives );
pOutputData[ i + iOutputOffset ] = fYOutput;
......@@ -173,12 +169,9 @@ bool CITASampleWindowedSincInterpolation::Interpolate( const ITASampleBuffer* pI
assert( iInputStartOffset >= m_iWindowSize / 2 );
assert( iOutputLength > 0 );
assert( pOutput->length() >= iOutputLength + iOutputOffset );
// Samples, die aufgeholt (>0) bzw. abgebremst (<0) werden mssen
int iDeltaDelay = ( iInputLength - iInputStartOffset ) - iOutputLength;
// Resamplingfaktor
float r = 1 + iDeltaDelay / ( float ) iOutputLength;
float r = iInputLength / ( float ) iOutputLength;
// --= Resampling =--
......@@ -189,22 +182,19 @@ bool CITASampleWindowedSincInterpolation::Interpolate( const ITASampleBuffer* pI
for( int i = 0; i < iOutputLength; i++ )
{
// Position in der Eingabe berechnen (relativ zum Anfang mit Offset)
float fXInput = ( i + 1 )*r - 1;
if( i == iOutputLength - 1 )
assert( iOutputLength + iDeltaDelay == iInputLength - iInputStartOffset );
float fXInput = ( i + 1 )*r + iInputStartOffset - 1;
// Fenster anwenden & Si-Rekonstruktion
pOutputData[ i + iOutputOffset ] = 0.0f;
for( int j = ( int ) ceil( fXInput - m_iWindowSize / 2 ); j < ( int ) floor( fXInput + m_iWindowSize / 2 ); j++ )
{
int iCenterIndex = j + iInputStartOffset;
int iCenterIndex = j;
assert( iCenterIndex >= 0 && iCenterIndex < iInputLength + m_iWindowSize / 2 ); // berlauf verhindern
float fAmplitude = pInputData[ iCenterIndex ];
// Relativer Abstand zum aktuellen Lesecursor in der Eingabe
float fSincArg = fXInput - iCenterIndex + iInputStartOffset;
float fSincArg = fXInput - iCenterIndex;
assert( std::fabs( fSincArg ) <= ( float ) m_iWindowSize / 2 ); // Fensterberlauf verhindern
float fSincValue = ( fSincArg != 0.0f ) ? ( sin( ITAConstants::PI_F * fSincArg ) / ( ITAConstants::PI_F * fSincArg ) ) : 1.0f;
......
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