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