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