annotate doc/ModuleTemplate.cc @ 16:2a5354042241

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