tomwalters@283: // Copyright #YEAR#, #AUTHOR_NAME# tomwalters@283: // tomwalters@283: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@283: // http://www.acousticscale.org/AIMC tomwalters@283: // tomwalters@283: // This program is free software: you can redistribute it and/or modify tomwalters@283: // it under the terms of the GNU General Public License as published by tomwalters@283: // the Free Software Foundation, either version 3 of the License, or tomwalters@283: // (at your option) any later version. tomwalters@283: // tomwalters@283: // This program is distributed in the hope that it will be useful, tomwalters@283: // but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@283: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@283: // GNU General Public License for more details. tomwalters@283: // tomwalters@283: // You should have received a copy of the GNU General Public License tomwalters@283: // along with this program. If not, see . tomwalters@283: tomwalters@283: /*! tomwalters@283: * \author #AUTHOR_NAME# <#AUTHOR_EMAIL_ADDRESS#> tomwalters@283: * \date created #TODAYS_DATE# tomwalters@283: * \version \$Id$ tomwalters@283: */ tomwalters@283: tomwalters@283: #include "Modules/#MODULE_TYPE#/#MODULE_NAME#.h" tomwalters@283: tomwalters@283: namespace aimc { tomwalters@283: #MODULE_NAME#::#MODULE_NAME#(Parameters *params) : Module(params) { tomwalters@283: module_description_ = "TODO: Short Description of the module"; tomwalters@283: module_identifier_ = "TODO: one-word id for the module"; tomwalters@283: module_type_ = "TODO: type code eg. bmm, sai"; tomwalters@283: module_version_ = "$Id$"; tomwalters@283: tomwalters@283: // Read parameter values from the parameter store. Setting any default tomwalters@283: // values as necessary. The module should set defaults for all parameters tomwalters@283: // that is uses here. The parameters_->DefaultType() methods look for a tomwalters@283: // parameter with a given name. If it already exists in the parameter tomwalters@283: // store, they return the current value. If the parameter doesn't already tomwalters@283: // exist, it is added, set to the default value given, and that value is tomwalters@283: // returned. tomwalters@283: // Examples: tomwalters@283: // integer_param_ = parameters_->DefaultInt("module.param_name", 4); tomwalters@284: // boolean_param_ = parameters_->DefaultBool("module.param_name", true); tomwalters@283: // float_param_ = parameters_->DefaultFloat("module.param_name", 4.4f); tomwalters@283: } tomwalters@283: tomwalters@283: #MODULE_NAME#::~#MODULE_NAME#() { tomwalters@283: } tomwalters@283: tomwalters@283: bool #MODULE_NAME#::InitializeInternal(const SignalBank &input) { tomwalters@283: // Copy the parameters of the input signal bank into internal variables, so tomwalters@283: // that they can be checked later. tomwalters@283: sample_rate_ = input.sample_rate(); tomwalters@283: buffer_length_ = input.buffer_length(); tomwalters@283: channel_count_ = input.channel_count(); tomwalters@283: tomwalters@283: // If this module produces any output, then the output signal bank needs to tomwalters@283: // be initialized here. tomwalters@283: // Example: tomwalters@283: // output_.Initialize(channel_count, buffer_length, sample_rate); tomwalters@283: return true; tomwalters@283: } tomwalters@283: tomwalters@283: void #MODULE_NAME#::ResetInternal() { tomwalters@283: // Reset any internal state variables to their default values here. After a tomwalters@283: // call to ResetInternal(), the module should be in the same state as it is tomwalters@283: // just after a call to InitializeInternal(). tomwalters@283: } tomwalters@283: tomwalters@283: void #MODULE_NAME#::Process(const SignalBank &input) { tomwalters@283: // Check to see if the module has been initialized. If not, processing tomwalters@283: // should not continue. tomwalters@283: if (!initialized_) { tomwalters@284: LOG_ERROR(_T("Module %s not initialized."), module_identifier_.c_str()); tomwalters@283: return; tomwalters@283: } tomwalters@283: tomwalters@283: // Check that ths input this time is the same as the input passed to tomwalters@283: // Initialize() tomwalters@283: if (buffer_length_ != input.buffer_length() tomwalters@283: || channel_count_ != input.channel_count()) { tomwalters@283: LOG_ERROR(_T("Mismatch between input to Initialize() and input to " tomwalters@284: "Process() in module %s."), module_identifier_.c_str()); tomwalters@283: return; tomwalters@283: } tomwalters@283: tomwalters@283: // Input is read from the input signal bank using calls like tomwalters@283: // float value = input_.sample(channel_number, sample_index); tomwalters@283: tomwalters@283: // Output is fed into the output signal bank (assuming that it was tomwalters@283: // initialized during the call to InitializeInternal()) like this: tomwalters@283: // output_.set_sample(channel_number, sample_index, sample_value); tomwalters@283: tomwalters@283: // If the output bank is set up, a call to PushOutput() will pass the output tomwalters@283: // on to all the target modules of this module. PushOutput() can be called tomwalters@283: // multiple times within each call to Process(). tomwalters@283: // Example: tomwalters@283: // PushOutput(); tomwalters@283: } tomwalters@283: } // namespace aimc tomwalters@283: