tomwalters@11: // Copyright #YEAR#, #AUTHOR_NAME# tomwalters@11: // tomwalters@11: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@11: // http://www.acousticscale.org/AIMC tomwalters@11: // tomwalters@45: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@45: // you may not use this file except in compliance with the License. tomwalters@45: // You may obtain a copy of the License at tomwalters@11: // tomwalters@45: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@11: // tomwalters@45: // Unless required by applicable law or agreed to in writing, software tomwalters@45: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@45: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@45: // See the License for the specific language governing permissions and tomwalters@45: // limitations under the License. tomwalters@11: tomwalters@11: /*! tomwalters@11: * \author #AUTHOR_NAME# <#AUTHOR_EMAIL_ADDRESS#> tomwalters@11: * \date created #TODAYS_DATE# tomwalters@11: * \version \$Id$ tomwalters@11: */ tomwalters@11: tomwalters@11: #include "Modules/#MODULE_TYPE#/#MODULE_NAME#.h" tomwalters@11: tomwalters@11: namespace aimc { tomwalters@11: #MODULE_NAME#::#MODULE_NAME#(Parameters *params) : Module(params) { tomwalters@11: module_description_ = "TODO: Short Description of the module"; tomwalters@11: module_identifier_ = "TODO: one-word id for the module"; tomwalters@11: module_type_ = "TODO: type code eg. bmm, sai"; tomwalters@11: module_version_ = "$Id$"; tomwalters@11: tomwalters@11: // Read parameter values from the parameter store. Setting any default tomwalters@11: // values as necessary. The module should set defaults for all parameters tomwalters@11: // that is uses here. The parameters_->DefaultType() methods look for a tomwalters@11: // parameter with a given name. If it already exists in the parameter tomwalters@11: // store, they return the current value. If the parameter doesn't already tomwalters@11: // exist, it is added, set to the default value given, and that value is tomwalters@11: // returned. tomwalters@11: // Examples: tomwalters@11: // integer_param_ = parameters_->DefaultInt("module.param_name", 4); tomwalters@12: // boolean_param_ = parameters_->DefaultBool("module.param_name", true); tomwalters@11: // float_param_ = parameters_->DefaultFloat("module.param_name", 4.4f); tomwalters@11: } tomwalters@11: tomwalters@11: #MODULE_NAME#::~#MODULE_NAME#() { tomwalters@11: } tomwalters@11: tomwalters@11: bool #MODULE_NAME#::InitializeInternal(const SignalBank &input) { tomwalters@11: // Copy the parameters of the input signal bank into internal variables, so tomwalters@11: // that they can be checked later. tomwalters@11: sample_rate_ = input.sample_rate(); tomwalters@11: buffer_length_ = input.buffer_length(); tomwalters@11: channel_count_ = input.channel_count(); tomwalters@11: tomwalters@11: // If this module produces any output, then the output signal bank needs to tomwalters@11: // be initialized here. tomwalters@11: // Example: tomwalters@11: // output_.Initialize(channel_count, buffer_length, sample_rate); tomwalters@11: return true; tomwalters@11: } tomwalters@11: tomwalters@11: void #MODULE_NAME#::ResetInternal() { tomwalters@11: // Reset any internal state variables to their default values here. After a tomwalters@11: // call to ResetInternal(), the module should be in the same state as it is tomwalters@11: // just after a call to InitializeInternal(). tomwalters@11: } tomwalters@11: tomwalters@11: void #MODULE_NAME#::Process(const SignalBank &input) { tomwalters@11: // Check to see if the module has been initialized. If not, processing tomwalters@11: // should not continue. tomwalters@11: if (!initialized_) { tomwalters@12: LOG_ERROR(_T("Module %s not initialized."), module_identifier_.c_str()); tomwalters@11: return; tomwalters@11: } tomwalters@11: tomwalters@11: // Check that ths input this time is the same as the input passed to tomwalters@11: // Initialize() tomwalters@11: if (buffer_length_ != input.buffer_length() tomwalters@11: || channel_count_ != input.channel_count()) { tomwalters@11: LOG_ERROR(_T("Mismatch between input to Initialize() and input to " tomwalters@12: "Process() in module %s."), module_identifier_.c_str()); tomwalters@11: return; tomwalters@11: } tomwalters@11: tomwalters@11: // Input is read from the input signal bank using calls like tomwalters@11: // float value = input_.sample(channel_number, sample_index); tomwalters@11: tomwalters@11: // Output is fed into the output signal bank (assuming that it was tomwalters@11: // initialized during the call to InitializeInternal()) like this: tomwalters@11: // output_.set_sample(channel_number, sample_index, sample_value); tomwalters@11: tomwalters@11: // If the output bank is set up, a call to PushOutput() will pass the output tomwalters@11: // on to all the target modules of this module. PushOutput() can be called tomwalters@11: // multiple times within each call to Process(). tomwalters@11: // Example: tomwalters@11: // PushOutput(); tomwalters@11: } tomwalters@11: } // namespace aimc tomwalters@11: