#ifndef FIR_FILTER_H
#define FIR_FILTER_H

#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

class FIR_filter
{
public:
    FIR_filter(int taps = 0, double f1 = 0, double f2 = 0, char *type = nullptr,
               char *window = nullptr);
    ~FIR_filter();

    std::vector<double> getCoefficients();

    double filter(double new_sample);

private:
    std::vector<double> lowPass_coefficient(int taps, double f);
    std::vector<double> highPass_coefficient(int taps, double f);
    std::vector<double> bandPass_coefficient(int taps, double f1, double f2);
    std::vector<double> bandStop_coefficient(int taps, double f1, double f2);

    std::vector<double> window_hammig(int taps);
    std::vector<double> window_triangle(int taps);
    std::vector<double> window_hanning(int taps);
    std::vector<double> window_blackman(int taps);

    std::vector<double> h;
    std::vector<double> samples;

    int idx = 0;
    int taps = 0;
};

#endif // FIR_FILTER_H
