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

#if !defined(_HARKLIB_NODE_GHDSS_H_INCLUDED_)
#define _HARKLIB_NODE_GHDSS_H_INCLUDED_ 1

#include "hark-lib/hark-lib.h"
#include "hark-lib/node.h"
#include "hark-lib/matrix.h"
#include "hark-lib/source.h"
#include "hark-lib/tensor.h"
#include "hark-lib/tf.h"

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

namespace hark
{
namespace node
{
    class GHDSS: public NodeDef
    {
    public:
        GHDSS();

        void initialize(InputDataBundle &input);
        virtual void reset();
        virtual bool operator () (size_t count, InputDataBundle &input, OutputDataBundle &output);

    private:
        int length;
        int advance;
        int sampling_rate;
        int lower_bound;
        int upper_bound;

        int lower_bin; // lower_bound * length / sampling_rate
        int upper_bin; // upper_bound * length / sampling_rate

        int enum_window;
        //int iFlgTf; // Flag for TF generation (0: ClacFree, 1: Read data file)
        //int iFlgW;  // Flag for Separation Matrix (0: Calc, 1: Read)

        float update_dist; // fUpdate_dist;

        bool req_init; // m_bFlgIni Initial process flag
        bool exportw; //bool m_bExpW;

        //std::string tf_conj_filename;
        //std::string initw_filename;
        std::string exportw_filename; // filename_expW;

        // num_ch * (upper_index - lower_index + 1)
        hark::FreqBins<std::complex<float> > InputSpec;
        hark::FreqBins<std::complex<float> > OutputSpec;

        //struct MICARY_PrmFrame PrmFrame;
        //float sampling_rate;
        //int nfft;
        //int shift;
        //int num_window;
        //enum WINDOW window; // hanning or special

        //GHDSS_exec::GHDSS_Params ghdss_params;
        //GHDSS_exec::PrmFrame ghdss_frame_params;
        GHDSS_exec ghdss_exec;
        std::vector<GHDSS_exec::Location> src_pos;

        struct CompareLocations {
            bool operator()(const GHDSS_exec::Location &a, const GHDSS_exec::Location &b) const noexcept {
                return a.idpos < b.idpos;
            }
        };

    };
}
}

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

/* end of file */
