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

#if !defined(_HARKLIB_NODE_SPECTRAL_MEAN_NORMALIZATION_INCREMENTAL_H_INCLUDED_)
#define _HARKLIB_NODE_SPECTRAL_MEAN_NORMALIZATION_INCREMENTAL_H_INCLUDED_ 1

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

#include "hark-lib/extlib/SpectralMeanMod.hpp"

#include <string>
#include <vector>
#include <map>
#include <fstream>

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

    private:
        void initialize(InputDataBundle &input);

    private:
        int fbank_count;
        int period;
        std::string sm_algorithm;
        std::vector<float>infileSM;
        bool b_sm_history_filename;
        std::vector<std::vector<float>>historySM;
        int ignore_frames;
        std::vector<float>prevSM;
        std::vector<float>curSM;
        std::map<int, SpectralMeanMod>mapSM;
        std::string basename;
        bool b_basename;
        std::map<int, shared_ptr<ofstream>>streams;
        std::string output_fname;
        bool b_output_fname;
        std::ofstream fout2;
        bool b_sm_export;
        std::string sm_export_filename;
        std::string sm_export_algorithm;
        std::vector<int>sm_export_nframe;
        std::vector<std::vector<float>>sm_export_sm;

    };
}
}

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

/* end of file */
