Giving multi channel FIR a namespace

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