Mercurial > hg > aimc
comparison doc/ModuleTemplate.cc @ 11:bd370910aa05
-Added modules template
-Changed header guard style to be more consistent with the Google style guide
-Added Doyxfile to generate doxygen documentation
-Added structure diagram
-Updated swig script to reflect new modules
-Changes Gaussians back to using floats and changed tolerance on tests - doubles are unnecessary here
author | tomwalters |
---|---|
date | Fri, 19 Feb 2010 12:15:56 +0000 |
parents | |
children | d67a0a83d11b |
comparison
equal
deleted
inserted
replaced
10:d54efba7f09b | 11:bd370910aa05 |
---|---|
1 // Copyright #YEAR#, #AUTHOR_NAME# | |
2 // | |
3 // AIM-C: A C++ implementation of the Auditory Image Model | |
4 // http://www.acousticscale.org/AIMC | |
5 // | |
6 // This program is free software: you can redistribute it and/or modify | |
7 // it under the terms of the GNU General Public License as published by | |
8 // the Free Software Foundation, either version 3 of the License, or | |
9 // (at your option) any later version. | |
10 // | |
11 // This program is distributed in the hope that it will be useful, | |
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 // GNU General Public License for more details. | |
15 // | |
16 // You should have received a copy of the GNU General Public License | |
17 // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 /*! | |
20 * \author #AUTHOR_NAME# <#AUTHOR_EMAIL_ADDRESS#> | |
21 * \date created #TODAYS_DATE# | |
22 * \version \$Id$ | |
23 */ | |
24 | |
25 #include "Modules/#MODULE_TYPE#/#MODULE_NAME#.h" | |
26 | |
27 namespace aimc { | |
28 #MODULE_NAME#::#MODULE_NAME#(Parameters *params) : Module(params) { | |
29 module_description_ = "TODO: Short Description of the module"; | |
30 module_identifier_ = "TODO: one-word id for the module"; | |
31 module_type_ = "TODO: type code eg. bmm, sai"; | |
32 module_version_ = "$Id$"; | |
33 | |
34 // Read parameter values from the parameter store. Setting any default | |
35 // values as necessary. The module should set defaults for all parameters | |
36 // that is uses here. The parameters_->DefaultType() methods look for a | |
37 // parameter with a given name. If it already exists in the parameter | |
38 // store, they return the current value. If the parameter doesn't already | |
39 // exist, it is added, set to the default value given, and that value is | |
40 // returned. | |
41 // Examples: | |
42 // integer_param_ = parameters_->DefaultInt("module.param_name", 4); | |
43 // boolean_param_ = parameters_->DefaultBool("module.param_name", True); | |
44 // float_param_ = parameters_->DefaultFloat("module.param_name", 4.4f); | |
45 } | |
46 | |
47 #MODULE_NAME#::~#MODULE_NAME#() { | |
48 } | |
49 | |
50 bool #MODULE_NAME#::InitializeInternal(const SignalBank &input) { | |
51 // Copy the parameters of the input signal bank into internal variables, so | |
52 // that they can be checked later. | |
53 sample_rate_ = input.sample_rate(); | |
54 buffer_length_ = input.buffer_length(); | |
55 channel_count_ = input.channel_count(); | |
56 | |
57 // If this module produces any output, then the output signal bank needs to | |
58 // be initialized here. | |
59 // Example: | |
60 // output_.Initialize(channel_count, buffer_length, sample_rate); | |
61 return true; | |
62 } | |
63 | |
64 void #MODULE_NAME#::ResetInternal() { | |
65 // Reset any internal state variables to their default values here. After a | |
66 // call to ResetInternal(), the module should be in the same state as it is | |
67 // just after a call to InitializeInternal(). | |
68 } | |
69 | |
70 void #MODULE_NAME#::Process(const SignalBank &input) { | |
71 // Check to see if the module has been initialized. If not, processing | |
72 // should not continue. | |
73 if (!initialized_) { | |
74 LOG_ERROR(_T("Module #MODULE_NAME# not initialized.")); | |
75 return; | |
76 } | |
77 | |
78 // Check that ths input this time is the same as the input passed to | |
79 // Initialize() | |
80 if (buffer_length_ != input.buffer_length() | |
81 || channel_count_ != input.channel_count()) { | |
82 LOG_ERROR(_T("Mismatch between input to Initialize() and input to " | |
83 "Process() in module %s", module_identifier_)); | |
84 return; | |
85 } | |
86 | |
87 // Input is read from the input signal bank using calls like | |
88 // float value = input_.sample(channel_number, sample_index); | |
89 | |
90 // Output is fed into the output signal bank (assuming that it was | |
91 // initialized during the call to InitializeInternal()) like this: | |
92 // output_.set_sample(channel_number, sample_index, sample_value); | |
93 | |
94 // If the output bank is set up, a call to PushOutput() will pass the output | |
95 // on to all the target modules of this module. PushOutput() can be called | |
96 // multiple times within each call to Process(). | |
97 // Example: | |
98 // PushOutput(); | |
99 } | |
100 } // namespace aimc | |
101 |