sness@618: // Copyright 2006-2010, Thomas Walters, Willem van Engen sness@618: // sness@618: // AIM-C: A C++ implementation of the Auditory Image Model sness@618: // http://www.acousticscale.org/AIMC sness@618: // sness@618: // Licensed under the Apache License, Version 2.0 (the "License"); sness@618: // you may not use this file except in compliance with the License. sness@618: // You may obtain a copy of the License at sness@618: // sness@618: // http://www.apache.org/licenses/LICENSE-2.0 sness@618: // sness@618: // Unless required by applicable law or agreed to in writing, software sness@618: // distributed under the License is distributed on an "AS IS" BASIS, sness@618: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. sness@618: // See the License for the specific language governing permissions and sness@618: // limitations under the License. sness@618: sness@618: /*! sness@618: * \file sness@618: * \brief File output to JSON format sness@618: * sness@618: * \author Thomas Walters sness@618: * \author Willem van Engen sness@618: * \date created 2006/10/30 sness@618: * \version \$Header$ sness@618: */ sness@618: sness@618: #ifndef AIMC_MODULES_OUTPUT_JSON_H_ sness@618: #define AIMC_MODULES_OUTPUT_JSON_H_ sness@618: sness@618: #include sness@618: #include sness@618: #include sness@618: sness@618: // using namespace std; sness@618: sness@618: #include "Support/Module.h" sness@618: #include "Support/SignalBank.h" sness@618: sness@618: namespace aimc { sness@618: class FileOutputJSON : public Module { sness@618: public: sness@618: /*! \brief Create a new file output for an JSON format file. sness@618: */ sness@618: explicit FileOutputJSON(Parameters *pParam); sness@618: ~FileOutputJSON(); sness@618: virtual void Process(const SignalBank &input); sness@618: private: sness@618: /*! \brief Initialize the output to JSON. sness@618: * \param *filename Filename of the ouptut file to be created. sness@618: * If the file exists it will be overwritten sness@618: * \return Returns true on success of initialization. sness@618: */ sness@618: bool OpenFile(string &filename); sness@618: bool CloseFile(); sness@618: bool OpenStrobesFile(string &filename); sness@618: bool CloseStrobesFile(); sness@618: sness@618: virtual bool InitializeInternal(const SignalBank &input); sness@618: virtual void ResetInternal(); sness@618: sness@618: void WriteHeader(); sness@618: sness@618: /*! \brief Whether initialization is done or not sness@618: */ sness@618: bool header_written_; sness@618: sness@618: /*! \brief Internal pointer to the output file sness@618: */ sness@618: // FILE *file_handle_; sness@618: // FILE *strobes_file_handle_; sness@618: std::ofstream file_handle_; sness@618: sness@618: /*! \brief Count of the number of samples in the file, written on close sness@618: */ sness@618: int frame_count_; sness@618: sness@618: int channel_count_; sness@618: int buffer_length_; sness@618: float sample_rate_; sness@618: float frame_period_ms_; sness@618: string file_suffix_; sness@618: bool dump_strobes_; sness@618: string strobes_file_suffix_; sness@618: }; sness@618: } // namespace aimc sness@618: sness@618: #endif // AIMC_MODULES_OUTPUT_JSON_H_ sness@618: