tomwalters@5
|
1 // Copyright 2010, Thomas Walters
|
tomwalters@0
|
2 //
|
tomwalters@0
|
3 // AIM-C: A C++ implementation of the Auditory Image Model
|
tomwalters@0
|
4 // http://www.acousticscale.org/AIMC
|
tomwalters@0
|
5 //
|
tomwalters@0
|
6 // This program is free software: you can redistribute it and/or modify
|
tomwalters@0
|
7 // it under the terms of the GNU General Public License as published by
|
tomwalters@0
|
8 // the Free Software Foundation, either version 3 of the License, or
|
tomwalters@0
|
9 // (at your option) any later version.
|
tomwalters@0
|
10 //
|
tomwalters@0
|
11 // This program is distributed in the hope that it will be useful,
|
tomwalters@0
|
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
tomwalters@0
|
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
tomwalters@0
|
14 // GNU General Public License for more details.
|
tomwalters@0
|
15 //
|
tomwalters@0
|
16 // You should have received a copy of the GNU General Public License
|
tomwalters@0
|
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
|
tomwalters@0
|
18
|
tomwalters@1
|
19 %module aimc
|
tomwalters@1
|
20 %include "std_string.i"
|
tomwalters@0
|
21 %{
|
tomwalters@0
|
22 #include "Support/Common.h"
|
tomwalters@0
|
23 #include "Support/Module.h"
|
tomwalters@0
|
24 #include "Support/Parameters.h"
|
tomwalters@0
|
25 #include "Support/SignalBank.h"
|
tomwalters@0
|
26 #include "Modules/Features/ModuleGaussians.h"
|
tomwalters@5
|
27 #include "Modules/BMM/ModuleGammatone.h"
|
tomwalters@0
|
28 %}
|
tomwalters@0
|
29
|
tomwalters@0
|
30 namespace aimc {
|
tomwalters@0
|
31 class Parameters {
|
tomwalters@0
|
32 public:
|
tomwalters@0
|
33 Parameters();
|
tomwalters@0
|
34 ~Parameters();
|
tomwalters@0
|
35 bool Load(const char *sParamFilename);
|
tomwalters@0
|
36 bool Save(const char *sParamFilename);
|
tomwalters@1
|
37 std::string WriteString();
|
tomwalters@0
|
38 bool Merge(const char *sParamFilename);
|
tomwalters@1
|
39 const char* DefaultString(const char *sName, const char *val);
|
tomwalters@1
|
40 int DefaultInt(const char *sName, int val);
|
tomwalters@1
|
41 unsigned int DefaultUInt(const char *sName, unsigned int val);
|
tomwalters@1
|
42 float DefaultFloat(const char *sName, float val);
|
tomwalters@1
|
43 bool DefaultBool(const char *sName, bool val);
|
tomwalters@0
|
44 void SetString(const char *sName, const char *val);
|
tomwalters@0
|
45 void SetInt(const char *sName, int val);
|
tomwalters@0
|
46 void SetUInt(const char *sName, unsigned int val);
|
tomwalters@0
|
47 void SetFloat(const char *sName, float val);
|
tomwalters@0
|
48 void SetBool(const char *sName, bool val);
|
tomwalters@0
|
49 const char *GetString(const char *sName);
|
tomwalters@0
|
50 int GetInt(const char *sName);
|
tomwalters@0
|
51 unsigned int GetUInt(const char *sName);
|
tomwalters@0
|
52 float GetFloat(const char *sName);
|
tomwalters@0
|
53 bool GetBool(const char *sName);
|
tomwalters@0
|
54 bool IsSet(const char *sName);
|
tomwalters@0
|
55 bool Parse(const char *sCmd);
|
tomwalters@0
|
56 bool Delete(const char *sName);
|
tomwalters@0
|
57 static const unsigned int MaxParamNameLength = 128;
|
tomwalters@0
|
58 };
|
tomwalters@0
|
59
|
tomwalters@0
|
60 class SignalBank {
|
tomwalters@0
|
61 public:
|
tomwalters@1
|
62 SignalBank();
|
tomwalters@1
|
63 ~SignalBank();
|
tomwalters@1
|
64 bool Initialize(int channel_count, int signal_length, float sample_rate);
|
tomwalters@1
|
65 bool Initialize(const SignalBank &input);
|
tomwalters@1
|
66 bool Validate() const;
|
tomwalters@1
|
67 const vector<float> &operator[](int channel) const;
|
tomwalters@1
|
68 float sample(int channel, int index) const;
|
tomwalters@1
|
69 void set_sample(int channel, int index, float value);
|
tomwalters@1
|
70 float sample_rate() const;
|
tomwalters@1
|
71 int buffer_length() const;
|
tomwalters@1
|
72 int start_time() const;
|
tomwalters@1
|
73 void set_start_time(int start_time);
|
tomwalters@11
|
74 float centre_frequency(int i) const;
|
tomwalters@1
|
75 void set_centre_frequency(int i, float cf);
|
tomwalters@1
|
76 bool initialized() const;
|
tomwalters@1
|
77 int channel_count() const;
|
tomwalters@0
|
78 };
|
tomwalters@0
|
79
|
tomwalters@0
|
80 class Module {
|
tomwalters@0
|
81 public:
|
tomwalters@0
|
82 explicit Module(Parameters *parameters);
|
tomwalters@0
|
83 virtual ~Module();
|
tomwalters@0
|
84 bool Initialize(const SignalBank &input);
|
tomwalters@0
|
85 bool initialized() const;
|
tomwalters@0
|
86 bool AddTarget(Module* target_module);
|
tomwalters@11
|
87 bool RemoveTarget(Module* target_module);
|
tomwalters@11
|
88 void RemoveAllTargets();
|
tomwalters@0
|
89 virtual void Process(const SignalBank &input) = 0;
|
tomwalters@0
|
90 virtual void Reset() = 0;
|
tomwalters@0
|
91 const SignalBank* GetOutputBank() const;
|
tomwalters@0
|
92 private:
|
tomwalters@0
|
93 DISALLOW_COPY_AND_ASSIGN(Module);
|
tomwalters@0
|
94 };
|
tomwalters@0
|
95
|
tomwalters@0
|
96 class ModuleGaussians : public Module
|
tomwalters@0
|
97 {
|
tomwalters@0
|
98 public:
|
tomwalters@0
|
99 ModuleGaussians(Parameters *pParam);
|
tomwalters@0
|
100 virtual ~ModuleGaussians();
|
tomwalters@0
|
101 virtual void Process(const SignalBank &input);
|
tomwalters@0
|
102 void Reset();
|
tomwalters@0
|
103 };
|
tomwalters@5
|
104
|
tomwalters@5
|
105 class ModuleGammatone : public Module
|
tomwalters@5
|
106 {
|
tomwalters@5
|
107 public:
|
tomwalters@5
|
108 ModuleGammatone(Parameters *pParam);
|
tomwalters@5
|
109 virtual ~ModuleGammatone();
|
tomwalters@5
|
110 virtual void Process(const SignalBank &input);
|
tomwalters@5
|
111 void Reset();
|
tomwalters@5
|
112 };
|
tomwalters@0
|
113 } // namespace aimc
|
tomwalters@0
|
114
|