tomwalters@268
|
1 // Copyright 2007-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 /*!
|
tomwalters@268
|
20 * \file
|
tomwalters@268
|
21 * \brief Modifiable List of Strobe Points - helper for SAI generation
|
tomwalters@268
|
22 *
|
tomwalters@268
|
23 * \author Tom Walters <tcw24@cam.ac.uk>
|
tomwalters@268
|
24 * \date created 2007/08/22
|
tomwalters@268
|
25 * \version \$Id: StrobeList.h 1 2010-02-02 11:04:50Z tcw $
|
tomwalters@268
|
26 */
|
tomwalters@268
|
27
|
tomwalters@277
|
28 #ifndef _AIMC_SUPPORT_STROBE_LIST_H_
|
tomwalters@277
|
29 #define _AIMC_SUPPORT_STROBE_LIST_H_
|
tomwalters@268
|
30
|
tomwalters@280
|
31 #include <math.h>
|
tomwalters@277
|
32 #include <deque>
|
tomwalters@268
|
33
|
tomwalters@277
|
34 namespace aimc {
|
tomwalters@277
|
35 using std::deque;
|
tomwalters@277
|
36 struct StrobePoint {
|
tomwalters@277
|
37 int time;
|
tomwalters@277
|
38 float weight;
|
tomwalters@277
|
39 float working_weight;
|
tomwalters@268
|
40 StrobePoint() {
|
tomwalters@280
|
41 time = 0;
|
tomwalters@280
|
42 weight = 0.0f;
|
tomwalters@280
|
43 working_weight = 0.0f;
|
tomwalters@268
|
44 }
|
tomwalters@268
|
45 };
|
tomwalters@268
|
46
|
tomwalters@268
|
47 /*!
|
tomwalters@268
|
48 * \class Signal "Support/StrobeList.h"
|
tomwalters@268
|
49 * \brief Modifiable List of Strobe Points, which must be ordered
|
tomwalters@268
|
50 *
|
tomwalters@268
|
51 */
|
tomwalters@268
|
52 class StrobeList {
|
tomwalters@268
|
53 public:
|
tomwalters@268
|
54 /*! \brief Create a new strobe list
|
tomwalters@268
|
55 */
|
tomwalters@268
|
56 inline StrobeList() {
|
tomwalters@277
|
57 strobes_.resize(0);
|
tomwalters@268
|
58 };
|
tomwalters@268
|
59
|
tomwalters@268
|
60 inline ~StrobeList() {
|
tomwalters@268
|
61 };
|
tomwalters@268
|
62
|
tomwalters@280
|
63 /*! \brief Return the strobe time (in samples, can be negative)
|
tomwalters@280
|
64 */
|
tomwalters@277
|
65 inline StrobePoint Strobe(int strobe_number) {
|
tomwalters@277
|
66 return strobes_.at(strobe_number);
|
tomwalters@268
|
67 };
|
tomwalters@268
|
68
|
tomwalters@280
|
69 /*! \brief Set the strobe weight
|
tomwalters@280
|
70 */
|
tomwalters@277
|
71 inline void SetWeight(int strobe_number, float weight) {
|
tomwalters@277
|
72 strobes_.at(strobe_number).weight = weight;
|
tomwalters@268
|
73 };
|
tomwalters@268
|
74
|
tomwalters@280
|
75 /*! \brief Set the strobe's working weight
|
tomwalters@280
|
76 */
|
tomwalters@277
|
77 inline void SetWorkingWeight(int strobe_number, float working_weight) {
|
tomwalters@277
|
78 strobes_.at(strobe_number).working_weight = working_weight;
|
tomwalters@268
|
79 };
|
tomwalters@268
|
80
|
tomwalters@280
|
81 /*! \brief Add a strobe to the list (must be in order)
|
tomwalters@280
|
82 */
|
tomwalters@277
|
83 inline void AddStrobe(int time, float weight) {
|
tomwalters@277
|
84 StrobePoint s;
|
tomwalters@277
|
85 s.time = time;
|
tomwalters@277
|
86 s.weight = weight;
|
tomwalters@277
|
87 strobes_.push_back(s);
|
tomwalters@268
|
88 };
|
tomwalters@268
|
89
|
tomwalters@280
|
90 /*! \brief Delete a strobe from the list
|
tomwalters@280
|
91 */
|
tomwalters@277
|
92 inline void DeleteFirstStrobe() {
|
tomwalters@277
|
93 strobes_.pop_front();
|
tomwalters@268
|
94 };
|
tomwalters@268
|
95
|
tomwalters@280
|
96 /*! \brief Get the number of strobes
|
tomwalters@280
|
97 */
|
tomwalters@277
|
98 inline int strobe_count() const {
|
tomwalters@277
|
99 return strobes_.size();
|
tomwalters@268
|
100 };
|
tomwalters@268
|
101
|
tomwalters@280
|
102 /*! \brief Shift the position of all strobes by subtracting offset from
|
tomwalters@280
|
103 * the time value of each
|
tomwalters@280
|
104 */
|
tomwalters@277
|
105 inline void ShiftStrobes(int offset) {
|
tomwalters@277
|
106 for (unsigned int i = 0; i < strobes_.size(); ++i)
|
tomwalters@277
|
107 strobes_[i].time -= offset;
|
tomwalters@268
|
108 };
|
tomwalters@268
|
109
|
tomwalters@268
|
110 private:
|
tomwalters@277
|
111 deque<StrobePoint> strobes_;
|
tomwalters@268
|
112 };
|
tomwalters@277
|
113 } // namespace aimc
|
tomwalters@268
|
114
|
tomwalters@268
|
115 #endif /* _AIMC_STROBE_LIST_H_ */
|
tomwalters@268
|
116
|