annotate src/Modules/Output/FileOutputJSON.h @ 611:0fbaf443ec82

Carfac C++ revision 3, indluding more style improvements. The output structs are now classes again, and have separate storage methods for each output structure along with flags in the Run and RunSegment methods to allow for only storing NAPs if desired.
author alexbrandmeyer
date Fri, 17 May 2013 19:52:45 +0000
parents 49eef19e4f1d
children
rev   line source
sness@607 1 // Copyright 2006-2010, Thomas Walters, Willem van Engen
sness@607 2 //
sness@607 3 // AIM-C: A C++ implementation of the Auditory Image Model
sness@607 4 // http://www.acousticscale.org/AIMC
sness@607 5 //
sness@607 6 // Licensed under the Apache License, Version 2.0 (the "License");
sness@607 7 // you may not use this file except in compliance with the License.
sness@607 8 // You may obtain a copy of the License at
sness@607 9 //
sness@607 10 // http://www.apache.org/licenses/LICENSE-2.0
sness@607 11 //
sness@607 12 // Unless required by applicable law or agreed to in writing, software
sness@607 13 // distributed under the License is distributed on an "AS IS" BASIS,
sness@607 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sness@607 15 // See the License for the specific language governing permissions and
sness@607 16 // limitations under the License.
sness@607 17
sness@607 18 /*!
sness@607 19 * \file
sness@607 20 * \brief File output to JSON format
sness@607 21 *
sness@607 22 * \author Thomas Walters <tom@acousticscale.org>
sness@607 23 * \author Willem van Engen <cnbh@willem.engen.nl>
sness@607 24 * \date created 2006/10/30
sness@607 25 * \version \$Header$
sness@607 26 */
sness@607 27
sness@607 28 #ifndef AIMC_MODULES_OUTPUT_JSON_H_
sness@607 29 #define AIMC_MODULES_OUTPUT_JSON_H_
sness@607 30
sness@607 31 #include <string>
sness@607 32 #include <iostream>
sness@607 33 #include <fstream>
sness@607 34
sness@607 35 // using namespace std;
sness@607 36
sness@607 37 #include "Support/Module.h"
sness@607 38 #include "Support/SignalBank.h"
sness@607 39
sness@607 40 namespace aimc {
sness@607 41 class FileOutputJSON : public Module {
sness@607 42 public:
sness@607 43 /*! \brief Create a new file output for an JSON format file.
sness@607 44 */
sness@607 45 explicit FileOutputJSON(Parameters *pParam);
sness@607 46 ~FileOutputJSON();
sness@607 47 virtual void Process(const SignalBank &input);
sness@607 48 private:
sness@607 49 /*! \brief Initialize the output to JSON.
sness@607 50 * \param *filename Filename of the ouptut file to be created.
sness@607 51 * If the file exists it will be overwritten
sness@607 52 * \return Returns true on success of initialization.
sness@607 53 */
sness@607 54 bool OpenFile(string &filename);
sness@607 55 bool CloseFile();
sness@607 56 bool OpenStrobesFile(string &filename);
sness@607 57 bool CloseStrobesFile();
sness@607 58
sness@607 59 virtual bool InitializeInternal(const SignalBank &input);
sness@607 60 virtual void ResetInternal();
sness@607 61
sness@607 62 void WriteHeader();
sness@607 63
sness@607 64 /*! \brief Whether initialization is done or not
sness@607 65 */
sness@607 66 bool header_written_;
sness@607 67
sness@607 68 /*! \brief Internal pointer to the output file
sness@607 69 */
sness@607 70 // FILE *file_handle_;
sness@607 71 // FILE *strobes_file_handle_;
sness@607 72 std::ofstream file_handle_;
sness@607 73
sness@607 74 /*! \brief Count of the number of samples in the file, written on close
sness@607 75 */
sness@607 76 int frame_count_;
sness@607 77
sness@607 78 int channel_count_;
sness@607 79 int buffer_length_;
sness@607 80 float sample_rate_;
sness@607 81 float frame_period_ms_;
sness@607 82 string file_suffix_;
sness@607 83 bool dump_strobes_;
sness@607 84 string strobes_file_suffix_;
sness@607 85 };
sness@607 86 } // namespace aimc
sness@607 87
sness@607 88 #endif // AIMC_MODULES_OUTPUT_JSON_H_
sness@607 89