Giving multi channel FIR a namespace

parent d9968dd8
......@@ -23,38 +23,41 @@
#include <ITABaseDefinitions.h>
#include <ITASampleFrame.h>
//! Multichannel finite impulse response class / FIR filters
/**
namespace ITABase
{
//! Multichannel finite impulse response class / FIR filters
/**
* ITASampleFrame with a sampling rate = multichannel finite impulse response.
*/
class ITA_BASE_API CITAMultichannelFiniteImpulseResponse : public ITASampleFrame
{
public:
class ITA_BASE_API CMultichannelFiniteImpulseResponse : public ITASampleFrame
{
public:
//! Create empty FIR filters
/**
* Requires initialization to be used, otherwise methods will throw ITAException.
*/
CITAMultichannelFiniteImpulseResponse();
CMultichannelFiniteImpulseResponse();
//! Create FIR filter of certain size with given sampling frequency
/**
* \param iLength Length (size) of buffer in samples
*/
explicit CITAMultichannelFiniteImpulseResponse( const int iNumChannels, const int iLength, const double dSampleRate, const bool bZeroInit = true );
explicit CMultichannelFiniteImpulseResponse( const int iNumChannels, const int iLength, const double dSampleRate, const bool bZeroInit = true );
//! Copy constructor as pointer
/**
* \param pSource Pointer to source buffer
*/
CITAMultichannelFiniteImpulseResponse( const CITAMultichannelFiniteImpulseResponse* pSource );
CMultichannelFiniteImpulseResponse( const CMultichannelFiniteImpulseResponse* pSource );
//! Copy constructor as reference
/**
* \param pbSource Reference to source buffer
*/
CITAMultichannelFiniteImpulseResponse( const CITAMultichannelFiniteImpulseResponse& sbSource );
CMultichannelFiniteImpulseResponse( const CMultichannelFiniteImpulseResponse& sbSource );
virtual inline ~CITAMultichannelFiniteImpulseResponse() {};
virtual inline ~CMultichannelFiniteImpulseResponse() {};
//! Load from file constructor (audiofile)
/**
......@@ -62,7 +65,7 @@ public:
*
* @note Will throw ITAException on error.
*/
CITAMultichannelFiniteImpulseResponse( const std::string& sFilePath );
CMultichannelFiniteImpulseResponse( const std::string& sFilePath );
//! Loads FIR from file (will re-init length, if necessary)
void LoadFromFile( const std::string& sFilePath );
......@@ -86,14 +89,15 @@ public:
*/
void Init( const int iNumChannels, const int iLength, const double dSampleRate, const bool bZeroInit = true );
private:
private:
//! Disable these methods from ITASampleFrame
void Init( int, int, bool );
void Load( const std::string& );
void Load( const std::string&, double& );
void Store( const std::string&, double);
void Store( const std::string&, double );
double m_dSampleRate; //!< Sampling rate
};
};
}
#endif // INCLUDE_WATCHER_ITA_MULTICHANNEL_FINITE_IMPULSE_RESPONSE
#include <ITAMultichannelFiniteImpulseResponse.h>
#include <ITAException.h>
CITAMultichannelFiniteImpulseResponse::CITAMultichannelFiniteImpulseResponse()
ITABase::CMultichannelFiniteImpulseResponse::CMultichannelFiniteImpulseResponse()
: m_dSampleRate( 0 )
{
}
CITAMultichannelFiniteImpulseResponse::CITAMultichannelFiniteImpulseResponse( const int iNumChannels, const int iLength, const double dSampleRate, const bool bZeroInit /*= true */ )
ITABase::CMultichannelFiniteImpulseResponse::CMultichannelFiniteImpulseResponse( const int iNumChannels, const int iLength, const double dSampleRate, const bool bZeroInit /*= true */ )
: ITASampleFrame( iNumChannels, iLength, bZeroInit )
, m_dSampleRate( dSampleRate )
{
}
CITAMultichannelFiniteImpulseResponse::CITAMultichannelFiniteImpulseResponse( const CITAMultichannelFiniteImpulseResponse* pSource )
ITABase::CMultichannelFiniteImpulseResponse::CMultichannelFiniteImpulseResponse( const CMultichannelFiniteImpulseResponse* pSource )
{
Init( pSource->channels(), pSource->GetLength(), pSource->GetSampleRate() );
ITASampleFrame::write( pSource, pSource->GetLength() );
}
CITAMultichannelFiniteImpulseResponse::CITAMultichannelFiniteImpulseResponse( const CITAMultichannelFiniteImpulseResponse& sbSource )
ITABase::CMultichannelFiniteImpulseResponse::CMultichannelFiniteImpulseResponse( const CMultichannelFiniteImpulseResponse& sbSource )
{
Init( sbSource.GetNumChannels(), sbSource.GetLength(), sbSource.GetSampleRate() );
ITASampleFrame::write( sbSource, sbSource.GetLength() );
}
void CITAMultichannelFiniteImpulseResponse::Init( const int iNumChannels, const int iLength, const double dSampleRate, const bool bZeroInit /*= true */ )
void ITABase::CMultichannelFiniteImpulseResponse::Init( const int iNumChannels, const int iLength, const double dSampleRate, const bool bZeroInit /*= true */ )
{
m_dSampleRate = dSampleRate;
ITASampleFrame::Init( iNumChannels, iLength, bZeroInit );
}
double CITAMultichannelFiniteImpulseResponse::GetSampleRate() const
double ITABase::CMultichannelFiniteImpulseResponse::GetSampleRate() const
{
return m_dSampleRate;
}
double CITAMultichannelFiniteImpulseResponse::GetNyquistFrequency() const
double ITABase::CMultichannelFiniteImpulseResponse::GetNyquistFrequency() const
{
return GetSampleRate() / 2.0f;
}
void CITAMultichannelFiniteImpulseResponse::LoadFromFile( const std::string& sFilePath )
void ITABase::CMultichannelFiniteImpulseResponse::LoadFromFile( const std::string& sFilePath )
{
ITASampleFrame::Load( sFilePath, m_dSampleRate );
}
void CITAMultichannelFiniteImpulseResponse::StoreToFile( const std::string& sFilePath ) const
void ITABase::CMultichannelFiniteImpulseResponse::StoreToFile( const std::string& sFilePath ) const
{
if( GetNumChannels() <= 0 || GetSampleRate() <= 0.0f )
ITA_EXCEPT1( INVALID_PARAMETER, "Trying to store a multichannel FIR filter with no channels or invalid sampling rate" );
......
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