/*
   HARK Library
   Copyright (C) 2021 Honda Research Institute Japan Inc.
 */

#if !defined(_HARKLIB_NODE_MEL_FILTER_BANK_H_INCLUDED_)
#define _HARKLIB_NODE_MEL_FILTER_BANK_H_INCLUDED_ 1

#include "hark-lib/hark-lib.h"
#include "hark-lib/node.h"

#include <vector>

namespace hark
{
namespace node
{
    class MelFilterBank: public NodeDef
    {
    public:
        MelFilterBank();
        virtual void reset();
        virtual bool operator () (size_t count, InputDataBundle &input, OutputDataBundle &output);

    private:
        void initialize(InputDataBundle &input);
        void initialize_filters();
        void filter(const std::vector<float> &spec, std::vector<float> &fbank);

    private:
        int _length;
        int _sampling_rate;
        int _cutoff;
        int _fbank_count;
        int _lo;
        int _hi;
        std::vector<float>_spectrum;

        std::vector<short>_lo_index;
        std::vector<float>_lo_weight;
        std::vector<float>_mel_center;
    };
}
}

#endif /* #if !defined(_HARKLIB_NODE_MEL_FILTER_BANK_H_INCLUDED_) */

/* end of file */
