#include #include #include #include #include "rtfir.hpp" // Some math.h implementations don't define M_PI #ifndef M_PI #define M_PI 3.14159265358979323846 #endif /*!\brief Constructor for base FIR object * \param Taps Number of taps in the filter */ RTFIR::RTFIR(const unsigned int &Taps){ coeff=new double[Taps]; buffer=new double[Taps]; memset(buffer,0,Taps*sizeof(double)); taps=Taps; } /*!\brief Deconstructor for base FIR object */ RTFIR::~RTFIR(){ delete [] coeff; delete [] buffer; } /*!\brief Filters input data * \param Sample Sample to filter * \return Filtered sample */ double RTFIR::Filter(const double &Sample){ // Roll back samplebuffer memmove(&buffer[1],&buffer[0],(taps-1)*sizeof(*buffer)); buffer[0]=Sample; // Perform multiplication double output=0; for(unsigned int i=0;i RTFIR::GetCoefficients() const{ std::vector c; c.resize(taps); for(unsigned int i=0;i0.5){ throw std::invalid_argument("Frequencies must be normalized"); } else{ int W=Taps/2; for(int i=-W;i0.5){ throw std::invalid_argument("Frequencies must be normalized"); } else{ int W=Taps/2; for(int i=-W;i0.5 || High<0.0 || High>0.5){ throw std::invalid_argument("Frequencies must be normalized"); } else{ int W=Taps/2; for(int i=-W;i0.5 || High<0.0 || High>0.5){ throw std::invalid_argument("Frequencies must be normalized"); } else{ int W=Taps/2; for(int i=-W;i