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 void Reset();
|
tomwalters@0
|
44
|
tomwalters@0
|
45 private:
|
tomwalters@0
|
46 /*! \brief Prepare the module
|
tomwalters@0
|
47 * \param input Input signal bank
|
tomwalters@0
|
48 * \param output true on success false on failure
|
tomwalters@0
|
49 */
|
tomwalters@0
|
50 bool InitializeInternal(const SignalBank &input);
|
tomwalters@0
|
51
|
tomwalters@0
|
52 //! \brief Temporary buffer for constructing the current SAI frame
|
tomwalters@0
|
53 SignalBank sai_temp_;
|
tomwalters@0
|
54
|
tomwalters@0
|
55 //! \brief List of strobes for each channel
|
tomwalters@0
|
56 vector<StrobeList> active_strobes_;
|
tomwalters@0
|
57
|
tomwalters@0
|
58 //! \brief Buffer decay parameter
|
tomwalters@0
|
59 float buffer_memory_decay_;
|
tomwalters@0
|
60
|
tomwalters@0
|
61 //! \brief Sample index of minimum strobe delay
|
tomwalters@0
|
62 int min_strobe_delay_idx_;
|
tomwalters@0
|
63
|
tomwalters@0
|
64 //! \brief Sample index of maximum strobe delay
|
tomwalters@0
|
65 int max_strobe_delay_idx_;
|
tomwalters@0
|
66
|
tomwalters@0
|
67 //! \brief Factor with which the SAI should be decayed
|
tomwalters@0
|
68 float sai_decay_factor_;
|
tomwalters@0
|
69
|
tomwalters@0
|
70 //! \brief Precomputed 1/n^alpha values for strobe weighting
|
tomwalters@0
|
71 vector<float> strobe_weights_;
|
tomwalters@0
|
72
|
tomwalters@0
|
73 //! \brief Next Strobe for each channels
|
tomwalters@0
|
74 vector<int> next_strobes_;
|
tomwalters@0
|
75
|
tomwalters@0
|
76 float strobe_weight_alpha_;
|
tomwalters@0
|
77
|
tomwalters@0
|
78 /*! \brief The maximum number strobes that can be active at the same time.
|
tomwalters@0
|
79 *
|
tomwalters@0
|
80 * A strobe lasts for strobe.maxdelay, there can only be a certain number
|
tomwalters@0
|
81 * of strobes active at the same time, that's this value. It's used for
|
tomwalters@0
|
82 * allocating memory buffers, like m_pUnfinishedStrobeCount and
|
tomwalters@0
|
83 * m_pStrobeWeights.
|
tomwalters@0
|
84 */
|
tomwalters@0
|
85 int max_concurrent_strobes_;
|
tomwalters@0
|
86
|
tomwalters@0
|
87 int fire_period_samples_;
|
tomwalters@0
|
88 int fire_counter_;
|
tomwalters@0
|
89
|
tomwalters@0
|
90 //! \brief Period in milliseconds between output frames
|
tomwalters@0
|
91 float output_frame_period_ms_;
|
tomwalters@0
|
92
|
tomwalters@0
|
93 //! \brief Time of the last frame output
|
tomwalters@0
|
94 float last_output_frame_time_ms_;
|
tomwalters@0
|
95 };
|
tomwalters@0
|
96 } // namespace aimc
|
tomwalters@0
|
97
|
tomwalters@0
|
98 #endif // _AIMC_MODULE_SAI_H_
|