Adding more methods for base classes

parent cabd76b0
...@@ -30,7 +30,7 @@ class ITASampleBuffer; ...@@ -30,7 +30,7 @@ class ITASampleBuffer;
* For equidistant sampling. * For equidistant sampling.
* *
*/ */
class IITAVDLInterpolationRoutine class IITASampleInterpolationRoutine
{ {
public: public:
//! Human-readable name //! Human-readable name
...@@ -70,37 +70,37 @@ public: ...@@ -70,37 +70,37 @@ public:
}; };
//! Linear interpolation (fast) //! Linear interpolation (fast)
class ITA_BASE_API CITAVDLLinearInterpolation : public IITAVDLInterpolationRoutine class ITA_BASE_API CITASampleLinearInterpolation : public IITASampleInterpolationRoutine
{ {
public: public:
inline CITAVDLLinearInterpolation() {}; inline CITASampleLinearInterpolation() {};
inline ~CITAVDLLinearInterpolation() {}; inline ~CITASampleLinearInterpolation() {};
inline std::string GetName() const { return "Linear Interpolation"; }; inline std::string GetName() const { return "Linear Interpolation"; };
inline void GetOverlapSamples( int& iLeft, int& iRight ) const { iLeft = 1; iRight = 0; }; inline void GetOverlapSamples( int& iLeft, int& iRight ) const { iLeft = 1; iRight = 0; };
bool Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset = 0 ) const; bool Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset = 0 ) const;
}; };
//! Cubic-Spline interpolation (efficient) //! Cubic-Spline interpolation (efficient)
class ITA_BASE_API CITAVDLCubicSplineInterpolation : public IITAVDLInterpolationRoutine class ITA_BASE_API CITASampleCubicSplineInterpolation : public IITASampleInterpolationRoutine
{ {
public: public:
inline CITAVDLCubicSplineInterpolation() {}; inline CITASampleCubicSplineInterpolation() {};
inline ~CITAVDLCubicSplineInterpolation() {}; inline ~CITASampleCubicSplineInterpolation() {};
inline std::string GetName() const { return "Cubic Spline Interpolation"; }; inline std::string GetName() const { return "Cubic Spline Interpolation"; };
inline void GetOverlapSamples( int& iLeft, int& iRight ) const { iLeft = 2; iRight = 2; }; inline void GetOverlapSamples( int& iLeft, int& iRight ) const { iLeft = 2; iRight = 2; };
bool Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset = 0 ) const; bool Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset = 0 ) const;
}; };
//! Windowed Sinc-Interpolation (costly) //! Windowed Sinc-Interpolation (costly)
class ITA_BASE_API CITAVDLWindowedSincInterpolation : public IITAVDLInterpolationRoutine class ITA_BASE_API CITASampleWindowedSincInterpolation : public IITASampleInterpolationRoutine
{ {
public: public:
inline CITAVDLWindowedSincInterpolation( const int iWindowSize = 13 ) : m_iWindowSize( iWindowSize ) inline CITASampleWindowedSincInterpolation( const int iWindowSize = 13 ) : m_iWindowSize( iWindowSize )
{ {
m_iWindowSize = m_iWindowSize + m_iWindowSize % 1; m_iWindowSize = m_iWindowSize + m_iWindowSize % 1;
}; };
inline ~CITAVDLWindowedSincInterpolation() {}; inline ~CITASampleWindowedSincInterpolation() {};
inline std::string GetName() const { return "Windowed Sinc-Interpolation"; }; inline std::string GetName() const { return "Windowed Sinc-Interpolation"; };
inline void GetOverlapSamples( int& iLeft, int& iRight ) const { iLeft = m_iWindowSize / 2; iRight = m_iWindowSize / 2; }; inline void GetOverlapSamples( int& iLeft, int& iRight ) const { iLeft = m_iWindowSize / 2; iRight = m_iWindowSize / 2; };
bool Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset = 0 ) const; bool Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset = 0 ) const;
......
...@@ -332,7 +332,7 @@ public: ...@@ -332,7 +332,7 @@ public:
std::string toString() const; std::string toString() const;
//! Werte als Zeichenkette zurckgeben //! Werte als Zeichenkette zurckgeben
std::string valuesToString() const; std::string ValuesToString() const;
//! berblendfunktionen //! berblendfunktionen
enum enum
......
...@@ -63,6 +63,9 @@ public: ...@@ -63,6 +63,9 @@ public:
//! Get a copy of the values (slow, do not use for read access) //! Get a copy of the values (slow, do not use for read access)
std::vector< float > GetValuesCopy() const; std::vector< float > GetValuesCopy() const;
//! Get values (read-only)
const std::vector< float >& GetValues() const;
//! Scalar multiplication //! Scalar multiplication
void Multiply( const float fFactor ); void Multiply( const float fFactor );
......
...@@ -10,7 +10,7 @@ void spline_cubic_set_equidistant( const int n, const float* y, float* ypp ); ...@@ -10,7 +10,7 @@ void spline_cubic_set_equidistant( const int n, const float* y, float* ypp );
// Evaluate cubic spline interpolation point using only base values (y) and second derivatives (ypp) for equidistant data // Evaluate cubic spline interpolation point using only base values (y) and second derivatives (ypp) for equidistant data
float spline_cubic_val_equidistant( const int n, const float fX, const float* y, const float* ypp ); float spline_cubic_val_equidistant( const int n, const float fX, const float* y, const float* ypp );
bool CITAVDLLinearInterpolation::Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset /*=0*/ ) const bool CITASampleLinearInterpolation::Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset /*=0*/ ) const
{ {
assert( pOutput->length() >= iOutputLength + iOutputOffset ); assert( pOutput->length() >= iOutputLength + iOutputOffset );
...@@ -138,7 +138,7 @@ bool CITAVDLLinearInterpolation::Interpolate( const ITASampleBuffer* pInput, con ...@@ -138,7 +138,7 @@ bool CITAVDLLinearInterpolation::Interpolate( const ITASampleBuffer* pInput, con
return false; return false;
} }
bool CITAVDLCubicSplineInterpolation::Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset /*=0*/ ) const bool CITASampleCubicSplineInterpolation::Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset /*=0*/ ) const
{ {
// Eingabe validieren // Eingabe validieren
assert( iInputStartOffset >= 2 ); assert( iInputStartOffset >= 2 );
...@@ -182,7 +182,7 @@ bool CITAVDLCubicSplineInterpolation::Interpolate( const ITASampleBuffer* pInput ...@@ -182,7 +182,7 @@ bool CITAVDLCubicSplineInterpolation::Interpolate( const ITASampleBuffer* pInput
return true; return true;
} }
bool CITAVDLWindowedSincInterpolation::Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset /*=0*/ ) const bool CITASampleWindowedSincInterpolation::Interpolate( const ITASampleBuffer* pInput, const int iInputLength, const int iInputStartOffset, ITASampleBuffer* pOutput, const int iOutputLength, const int iOutputOffset /*=0*/ ) const
{ {
// Eingabe validieren // Eingabe validieren
assert( iInputStartOffset >= m_iWindowSize / 2 ); assert( iInputStartOffset >= m_iWindowSize / 2 );
......
...@@ -9,6 +9,16 @@ CITAMagnitudeSpectrum::CITAMagnitudeSpectrum( const int nNumBands ) ...@@ -9,6 +9,16 @@ CITAMagnitudeSpectrum::CITAMagnitudeSpectrum( const int nNumBands )
SetValueUnit( "dB" ); SetValueUnit( "dB" );
} }
std::vector< float > CITAMagnitudeSpectrum::GetMagnitudesCopy() const
{
return CITASpectrum::GetValuesCopy();
}
const std::vector< float >& CITAMagnitudeSpectrum::GetMagnitudes() const
{
return CITASpectrum::GetValues();
}
void CITAMagnitudeSpectrum::SetMagnitudes( const std::vector< float >& vfMagnitudes ) void CITAMagnitudeSpectrum::SetMagnitudes( const std::vector< float >& vfMagnitudes )
{ {
CITASpectrum::SetValues( vfMagnitudes ); CITASpectrum::SetValues( vfMagnitudes );
......
...@@ -668,3 +668,13 @@ std::string ITASampleBuffer::toString() const ...@@ -668,3 +668,13 @@ std::string ITASampleBuffer::toString() const
ss << " }"; ss << " }";
return ss.str(); return ss.str();
} }
std::string ITASampleBuffer::ValuesToString() const
{
std::stringstream ss;
ss << "Sample buffer { ";
for( int i = 0; i < m_iLength; i++ )
ss << m_pfData[ i ] << " ";
ss << "}";
return ss.str();
}
...@@ -69,6 +69,11 @@ std::vector< float > CITASpectrum::GetValuesCopy() const ...@@ -69,6 +69,11 @@ std::vector< float > CITASpectrum::GetValuesCopy() const
return m_vfValues; return m_vfValues;
} }
const std::vector< float >& CITASpectrum::GetValues() const
{
return m_vfValues;
}
void CITASpectrum::Multiply( const float fFactor ) void CITASpectrum::Multiply( const float fFactor )
{ {
for( size_t n = 0; n < m_vfValues.size(); n++ ) for( size_t n = 0; n < m_vfValues.size(); n++ )
......
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