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@318
|
6 // Licensed under the Apache License, Version 2.0 (the "License");
|
tomwalters@318
|
7 // you may not use this file except in compliance with the License.
|
tomwalters@318
|
8 // You may obtain a copy of the License at
|
tomwalters@268
|
9 //
|
tomwalters@318
|
10 // http://www.apache.org/licenses/LICENSE-2.0
|
tomwalters@268
|
11 //
|
tomwalters@318
|
12 // Unless required by applicable law or agreed to in writing, software
|
tomwalters@318
|
13 // distributed under the License is distributed on an "AS IS" BASIS,
|
tomwalters@318
|
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
tomwalters@318
|
15 // See the License for the specific language governing permissions and
|
tomwalters@318
|
16 // limitations under the License.
|
tomwalters@268
|
17
|
tomwalters@268
|
18 /*!
|
tomwalters@268
|
19 * \file
|
tomwalters@268
|
20 * \brief Modifiable List of Strobe Points - helper for SAI generation
|
tomwalters@268
|
21 *
|
tomwalters@281
|
22 * \author Tom Walters <tom@acousticscale.org>
|
tomwalters@268
|
23 * \date created 2007/08/22
|
tomwalters@296
|
24 * \version \$Id$
|
tomwalters@268
|
25 */
|
tomwalters@268
|
26
|
tomwalters@283
|
27 #ifndef AIMC_SUPPORT_STROBELIST_H_
|
tomwalters@283
|
28 #define AIMC_SUPPORT_STROBELIST_H_
|
tomwalters@268
|
29
|
tomwalters@287
|
30 #include <cmath>
|
tomwalters@277
|
31 #include <deque>
|
tomwalters@268
|
32
|
tomwalters@277
|
33 namespace aimc {
|
tomwalters@277
|
34 using std::deque;
|
tomwalters@277
|
35 struct StrobePoint {
|
tomwalters@277
|
36 int time;
|
tomwalters@277
|
37 float weight;
|
tomwalters@277
|
38 float working_weight;
|
tomwalters@268
|
39 StrobePoint() {
|
tomwalters@280
|
40 time = 0;
|
tomwalters@280
|
41 weight = 0.0f;
|
tomwalters@280
|
42 working_weight = 0.0f;
|
tomwalters@268
|
43 }
|
tomwalters@268
|
44 };
|
tomwalters@268
|
45
|
tomwalters@268
|
46 class StrobeList {
|
tomwalters@268
|
47 public:
|
tomwalters@268
|
48 /*! \brief Create a new strobe list
|
tomwalters@268
|
49 */
|
tomwalters@268
|
50 inline StrobeList() {
|
tomwalters@277
|
51 strobes_.resize(0);
|
tomwalters@268
|
52 };
|
tomwalters@268
|
53
|
tomwalters@268
|
54 inline ~StrobeList() {
|
tomwalters@268
|
55 };
|
tomwalters@268
|
56
|
tomwalters@280
|
57 /*! \brief Return the strobe time (in samples, can be negative)
|
tomwalters@280
|
58 */
|
tomwalters@277
|
59 inline StrobePoint Strobe(int strobe_number) {
|
tomwalters@277
|
60 return strobes_.at(strobe_number);
|
tomwalters@268
|
61 };
|
tomwalters@268
|
62
|
tomwalters@280
|
63 /*! \brief Set the strobe weight
|
tomwalters@280
|
64 */
|
tomwalters@277
|
65 inline void SetWeight(int strobe_number, float weight) {
|
tomwalters@277
|
66 strobes_.at(strobe_number).weight = weight;
|
tomwalters@268
|
67 };
|
tomwalters@268
|
68
|
tomwalters@280
|
69 /*! \brief Set the strobe's working weight
|
tomwalters@280
|
70 */
|
tomwalters@277
|
71 inline void SetWorkingWeight(int strobe_number, float working_weight) {
|
tomwalters@277
|
72 strobes_.at(strobe_number).working_weight = working_weight;
|
tomwalters@268
|
73 };
|
tomwalters@268
|
74
|
tomwalters@280
|
75 /*! \brief Add a strobe to the list (must be in order)
|
tomwalters@280
|
76 */
|
tomwalters@277
|
77 inline void AddStrobe(int time, float weight) {
|
tomwalters@277
|
78 StrobePoint s;
|
tomwalters@277
|
79 s.time = time;
|
tomwalters@277
|
80 s.weight = weight;
|
tomwalters@277
|
81 strobes_.push_back(s);
|
tomwalters@268
|
82 };
|
tomwalters@268
|
83
|
tomwalters@280
|
84 /*! \brief Delete a strobe from the list
|
tomwalters@280
|
85 */
|
tomwalters@277
|
86 inline void DeleteFirstStrobe() {
|
tomwalters@277
|
87 strobes_.pop_front();
|
tomwalters@268
|
88 };
|
tomwalters@268
|
89
|
tomwalters@280
|
90 /*! \brief Get the number of strobes
|
tomwalters@280
|
91 */
|
tomwalters@277
|
92 inline int strobe_count() const {
|
tomwalters@277
|
93 return strobes_.size();
|
tomwalters@268
|
94 };
|
tomwalters@268
|
95
|
tomwalters@280
|
96 /*! \brief Shift the position of all strobes by subtracting offset from
|
tomwalters@280
|
97 * the time value of each
|
tomwalters@280
|
98 */
|
tomwalters@277
|
99 inline void ShiftStrobes(int offset) {
|
tomwalters@277
|
100 for (unsigned int i = 0; i < strobes_.size(); ++i)
|
tomwalters@277
|
101 strobes_[i].time -= offset;
|
tomwalters@268
|
102 };
|
tomwalters@268
|
103
|
tomwalters@268
|
104 private:
|
tomwalters@277
|
105 deque<StrobePoint> strobes_;
|
tomwalters@268
|
106 };
|
tomwalters@277
|
107 } // namespace aimc
|
tomwalters@268
|
108
|
tomwalters@283
|
109 #endif /* AIMC_SUPPORT_STROBELIST_H_ */
|
tomwalters@268
|
110
|