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@11: // This program is free software: you can redistribute it and/or modify tomwalters@11: // it under the terms of the GNU General Public License as published by tomwalters@11: // the Free Software Foundation, either version 3 of the License, or tomwalters@11: // (at your option) any later version. tomwalters@11: // tomwalters@11: // This program is distributed in the hope that it will be useful, tomwalters@11: // but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@11: // GNU General Public License for more details. tomwalters@11: // tomwalters@11: // You should have received a copy of the GNU General Public License tomwalters@11: // along with this program. If not, see . 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@11: // 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@11: LOG_ERROR(_T("Module #MODULE_NAME# not initialized.")); 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@11: "Process() in module %s", module_identifier_)); 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: