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

#if !defined(_HARKLIB_NODE_SAVE_VECTOR_FRAMES_H_INCLUDED_)
#define _HARKLIB_NODE_SAVE_VECTOR_FRAMES_H_INCLUDED_ 1

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

#include <random>
#include <string>
#include <vector>
#include <complex>

#include "fmt/format.h"

namespace hark
{
namespace node
{
    class SaveVectorFrames: public NodeDef
    {
    public:
        SaveVectorFrames();
        ~SaveVectorFrames();

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

    private:
        template <class T>
        inline int type(data &)

        enum class OutputMode : int64_t {
            TEXT = 0,
            RAW = 1
        };

        enum class TextMode : int64_t {
            FIXED = 0,
            SCIENTIFIC = 1
        };

        OutputMode mode;
        TextMode tmode;
        std::string filename;
        bool will_format_filename;
        std::ofstream fout;


        const float coef = 3.141592653589793238462643383279502884L * 2.0f;

        int length;
        float wn_level;
        float wn_factor;
        float wn_coef;

        std::mt19937 gen;
        std::uniform_real_distribution<float> rand_uniform;
    };
}
}

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

/* end of file */
