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

#if !defined(_HARKLIB_NODE_SAVE_WAVE_PCM_H_INCLUDED_)
#define _HARKLIB_NODE_SAVE_WAVE_PCM_H_INCLUDED_ 1

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

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

    private:
        void initialize(InputDataBundle &input);

    private:
        size_t _input_bits, _output_bits;
        size_t _advance, _sampling_rate;

        std::string _basename;
        bool _basename_has_format, _basename_has_azimuth, _basename_has_elevation;

        // for source-based output
        std::map<int, std::shared_ptr<std::ostream>> _streams;

        // for all-channel output
        std::shared_ptr<std::ostream> _all_channel_stream;
        std::string _last_file_name;
        size_t _last_frame_count;
    };
}
}

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

/* end of file */
