tomwalters@12
|
1 // Copyright 2010, Thomas Walters
|
tomwalters@12
|
2 //
|
tomwalters@12
|
3 // AIM-C: A C++ implementation of the Auditory Image Model
|
tomwalters@12
|
4 // http://www.acousticscale.org/AIMC
|
tomwalters@12
|
5 //
|
tomwalters@12
|
6 // This program is free software: you can redistribute it and/or modify
|
tomwalters@12
|
7 // it under the terms of the GNU General Public License as published by
|
tomwalters@12
|
8 // the Free Software Foundation, either version 3 of the License, or
|
tomwalters@12
|
9 // (at your option) any later version.
|
tomwalters@12
|
10 //
|
tomwalters@12
|
11 // This program is distributed in the hope that it will be useful,
|
tomwalters@12
|
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
tomwalters@12
|
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
tomwalters@12
|
14 // GNU General Public License for more details.
|
tomwalters@12
|
15 //
|
tomwalters@12
|
16 // You should have received a copy of the GNU General Public License
|
tomwalters@12
|
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
|
tomwalters@12
|
18
|
tomwalters@12
|
19 /*!
|
tomwalters@12
|
20 * \author Thomas Walters <tom@acousticscale.org>
|
tomwalters@12
|
21 * \date created 2010/02/19
|
tomwalters@12
|
22 * \version \$Id$
|
tomwalters@12
|
23 */
|
tomwalters@12
|
24
|
tomwalters@12
|
25 #include "Modules/SSI/ModuleSSI.h"
|
tomwalters@12
|
26
|
tomwalters@12
|
27 namespace aimc {
|
tomwalters@12
|
28 ModuleSSI::ModuleSSI(Parameters *params) : Module(params) {
|
tomwalters@12
|
29 module_description_ = "Size-shape image (aka the 'sscAI')";
|
tomwalters@12
|
30 module_identifier_ = "ssi";
|
tomwalters@12
|
31 module_type_ = "ssi";
|
tomwalters@12
|
32 module_version_ = "$Id$";
|
tomwalters@12
|
33
|
tomwalters@12
|
34 do_pitch_cutoff_ = parameters_->DefaultBool("ssi.pitch_cutoff", false);
|
tomwalters@12
|
35 }
|
tomwalters@12
|
36
|
tomwalters@12
|
37 ModuleSSI::~ModuleSSI() {
|
tomwalters@12
|
38 }
|
tomwalters@12
|
39
|
tomwalters@12
|
40 bool ModuleSSI::InitializeInternal(const SignalBank &input) {
|
tomwalters@12
|
41 // Copy the parameters of the input signal bank into internal variables, so
|
tomwalters@12
|
42 // that they can be checked later.
|
tomwalters@12
|
43 sample_rate_ = input.sample_rate();
|
tomwalters@12
|
44 buffer_length_ = input.buffer_length();
|
tomwalters@12
|
45 channel_count_ = input.channel_count();
|
tomwalters@12
|
46
|
tomwalters@12
|
47 // If this module produces any output, then the output signal bank needs to
|
tomwalters@12
|
48 // be initialized here.
|
tomwalters@12
|
49 // Example:
|
tomwalters@12
|
50 // output_.Initialize(channel_count, buffer_length, sample_rate);
|
tomwalters@12
|
51 return true;
|
tomwalters@12
|
52 }
|
tomwalters@12
|
53
|
tomwalters@12
|
54 void ModuleSSI::ResetInternal() {
|
tomwalters@12
|
55 // Reset any internal state variables to their default values here. After a
|
tomwalters@12
|
56 // call to ResetInternal(), the module should be in the same state as it is
|
tomwalters@12
|
57 // just after a call to InitializeInternal().
|
tomwalters@12
|
58 }
|
tomwalters@12
|
59
|
tomwalters@12
|
60 void ModuleSSI::Process(const SignalBank &input) {
|
tomwalters@12
|
61 // Check to see if the module has been initialized. If not, processing
|
tomwalters@12
|
62 // should not continue.
|
tomwalters@12
|
63 if (!initialized_) {
|
tomwalters@13
|
64 LOG_ERROR(_T("Module %s not initialized."), module_identifier_.c_str());
|
tomwalters@12
|
65 return;
|
tomwalters@12
|
66 }
|
tomwalters@12
|
67
|
tomwalters@12
|
68 // Check that ths input this time is the same as the input passed to
|
tomwalters@12
|
69 // Initialize()
|
tomwalters@12
|
70 if (buffer_length_ != input.buffer_length()
|
tomwalters@12
|
71 || channel_count_ != input.channel_count()) {
|
tomwalters@12
|
72 LOG_ERROR(_T("Mismatch between input to Initialize() and input to "
|
tomwalters@13
|
73 "Process() in module %s."), module_identifier_.c_str());
|
tomwalters@12
|
74 return;
|
tomwalters@12
|
75 }
|
tomwalters@12
|
76
|
tomwalters@12
|
77 // Input is read from the input signal bank using calls like
|
tomwalters@12
|
78 // float value = input_.sample(channel_number, sample_index);
|
tomwalters@12
|
79
|
tomwalters@12
|
80 // Output is fed into the output signal bank (assuming that it was
|
tomwalters@12
|
81 // initialized during the call to InitializeInternal()) like this:
|
tomwalters@12
|
82 // output_.set_sample(channel_number, sample_index, sample_value);
|
tomwalters@12
|
83
|
tomwalters@12
|
84 PushOutput();
|
tomwalters@12
|
85 }
|
tomwalters@12
|
86 } // namespace aimc
|
tomwalters@12
|
87
|