tomwalters@0
|
1 // Copyright 2006-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@0
|
19 /*! \file
|
tomwalters@0
|
20 * \brief SAI module
|
tomwalters@0
|
21 */
|
tomwalters@0
|
22
|
tomwalters@0
|
23 /*! \author Thomas Walters <tom@acousticscale.org>
|
tomwalters@0
|
24 * \date created 2007/08/29
|
tomwalters@0
|
25 * \version \$Id: ModuleSAI.h 4 2010-02-03 18:44:58Z tcw $
|
tomwalters@0
|
26 */
|
tomwalters@0
|
27 #ifndef _AIMC_MODULE_SAI_H_
|
tomwalters@0
|
28 #define _AIMC_MODULE_SAI_H_
|
tomwalters@0
|
29
|
tomwalters@0
|
30 #include <vector>
|
tomwalters@0
|
31
|
tomwalters@0
|
32 #include "Support/Module.h"
|
tomwalters@0
|
33 #include "Support/SignalBank.h"
|
tomwalters@0
|
34 #include "Support/StrobeList.h"
|
tomwalters@0
|
35
|
tomwalters@0
|
36 namespace aimc {
|
tomwalters@0
|
37 using std::vector;
|
tomwalters@0
|
38 class ModuleSAI : public Module {
|
tomwalters@0
|
39 public:
|
tomwalters@0
|
40 ModuleSAI(Parameters *parameters);
|
tomwalters@0
|
41 virtual ~ModuleSAI();
|
tomwalters@0
|
42 void Process(const SignalBank &input);
|
tomwalters@0
|
43
|
tomwalters@0
|
44 private:
|
tomwalters@0
|
45 /*! \brief Prepare the module
|
tomwalters@0
|
46 * \param input Input signal bank
|
tomwalters@0
|
47 * \param output true on success false on failure
|
tomwalters@0
|
48 */
|
tomwalters@0
|
49 bool InitializeInternal(const SignalBank &input);
|
tomwalters@0
|
50
|
tomwalters@3
|
51 virtual void ResetInternal();
|
tomwalters@3
|
52
|
tomwalters@0
|
53 //! \brief Temporary buffer for constructing the current SAI frame
|
tomwalters@0
|
54 SignalBank sai_temp_;
|
tomwalters@0
|
55
|
tomwalters@0
|
56 //! \brief List of strobes for each channel
|
tomwalters@0
|
57 vector<StrobeList> active_strobes_;
|
tomwalters@0
|
58
|
tomwalters@0
|
59 //! \brief Buffer decay parameter
|
tomwalters@0
|
60 float buffer_memory_decay_;
|
tomwalters@0
|
61
|
tomwalters@0
|
62 //! \brief Sample index of minimum strobe delay
|
tomwalters@0
|
63 int min_strobe_delay_idx_;
|
tomwalters@0
|
64
|
tomwalters@0
|
65 //! \brief Sample index of maximum strobe delay
|
tomwalters@0
|
66 int max_strobe_delay_idx_;
|
tomwalters@0
|
67
|
tomwalters@0
|
68 //! \brief Factor with which the SAI should be decayed
|
tomwalters@0
|
69 float sai_decay_factor_;
|
tomwalters@0
|
70
|
tomwalters@0
|
71 //! \brief Precomputed 1/n^alpha values for strobe weighting
|
tomwalters@0
|
72 vector<float> strobe_weights_;
|
tomwalters@0
|
73
|
tomwalters@0
|
74 //! \brief Next Strobe for each channels
|
tomwalters@0
|
75 vector<int> next_strobes_;
|
tomwalters@0
|
76
|
tomwalters@0
|
77 float strobe_weight_alpha_;
|
tomwalters@0
|
78
|
tomwalters@0
|
79 /*! \brief The maximum number strobes that can be active at the same time.
|
tomwalters@0
|
80 *
|
tomwalters@0
|
81 * A strobe lasts for strobe.maxdelay, there can only be a certain number
|
tomwalters@0
|
82 * of strobes active at the same time, that's this value. It's used for
|
tomwalters@0
|
83 * allocating memory buffers, like m_pUnfinishedStrobeCount and
|
tomwalters@0
|
84 * m_pStrobeWeights.
|
tomwalters@0
|
85 */
|
tomwalters@0
|
86 int max_concurrent_strobes_;
|
tomwalters@0
|
87
|
tomwalters@0
|
88 int fire_period_samples_;
|
tomwalters@0
|
89 int fire_counter_;
|
tomwalters@0
|
90
|
tomwalters@0
|
91 //! \brief Period in milliseconds between output frames
|
tomwalters@0
|
92 float output_frame_period_ms_;
|
tomwalters@0
|
93
|
tomwalters@0
|
94 //! \brief Time of the last frame output
|
tomwalters@0
|
95 float last_output_frame_time_ms_;
|
tomwalters@0
|
96 };
|
tomwalters@0
|
97 } // namespace aimc
|
tomwalters@0
|
98
|
tomwalters@0
|
99 #endif // _AIMC_MODULE_SAI_H_
|