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