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