comparison trunk/src/Modules/SAI/ModuleSAI.h @ 268:e14c70d1b171

- Initial add of support code and modules. Not everything is working yet.
author tomwalters
date Fri, 12 Feb 2010 12:31:23 +0000
parents
children ce2bab04f155
comparison
equal deleted inserted replaced
-1:000000000000 268:e14c70d1b171
1 // Copyright 2006-2010, Thomas Walters
2 //
3 // AIM-C: A C++ implementation of the Auditory Image Model
4 // http://www.acousticscale.org/AIMC
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 /*! \file
20 * \brief SAI module
21 */
22
23 /*! \author Thomas Walters <tom@acousticscale.org>
24 * \date created 2007/08/29
25 * \version \$Id: ModuleSAI.h 4 2010-02-03 18:44:58Z tcw $
26 */
27 #ifndef _AIMC_MODULE_SAI_H_
28 #define _AIMC_MODULE_SAI_H_
29
30 #include <vector>
31
32 #include "Support/Module.h"
33 #include "Support/SignalBank.h"
34 #include "Support/StrobeList.h"
35
36 namespace aimc {
37 using std::vector;
38 class ModuleSAI : public Module {
39 public:
40 ModuleSAI(Parameters *parameters);
41 virtual ~ModuleSAI();
42 void Process(const SignalBank &input);
43 void Reset();
44
45 private:
46 /*! \brief Prepare the module
47 * \param input Input signal bank
48 * \param output true on success false on failure
49 */
50 bool InitializeInternal(const SignalBank &input);
51
52 //! \brief Temporary buffer for constructing the current SAI frame
53 SignalBank sai_temp_;
54
55 //! \brief List of strobes for each channel
56 vector<StrobeList> active_strobes_;
57
58 //! \brief Buffer decay parameter
59 float buffer_memory_decay_;
60
61 //! \brief Sample index of minimum strobe delay
62 int min_strobe_delay_idx_;
63
64 //! \brief Sample index of maximum strobe delay
65 int max_strobe_delay_idx_;
66
67 //! \brief Factor with which the SAI should be decayed
68 float sai_decay_factor_;
69
70 //! \brief Precomputed 1/n^alpha values for strobe weighting
71 vector<float> strobe_weights_;
72
73 //! \brief Next Strobe for each channels
74 vector<int> next_strobes_;
75
76 float strobe_weight_alpha_;
77
78 /*! \brief The maximum number strobes that can be active at the same time.
79 *
80 * A strobe lasts for strobe.maxdelay, there can only be a certain number
81 * of strobes active at the same time, that's this value. It's used for
82 * allocating memory buffers, like m_pUnfinishedStrobeCount and
83 * m_pStrobeWeights.
84 */
85 int max_concurrent_strobes_;
86
87 int fire_period_samples_;
88 int fire_counter_;
89
90 //! \brief Period in milliseconds between output frames
91 float output_frame_period_ms_;
92
93 //! \brief Time of the last frame output
94 float last_output_frame_time_ms_;
95 };
96 } // namespace aimc
97
98 #endif // _AIMC_MODULE_SAI_H_