annotate src/Support/StrobeList.h @ 8:fcbf85ce59fb

- Lots of changes to make cpplint happy. It still complains about header guards, but that's pretty much it now.
author tomwalters
date Thu, 18 Feb 2010 21:12:41 +0000
parents 3c782dec2fc0
children 3078854c634a
rev   line source
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@8 31 #include <math.h>
tomwalters@5 32 #include <deque>
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@8 41 time = 0;
tomwalters@8 42 weight = 0.0f;
tomwalters@8 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@8 63 /*! \brief Return the strobe time (in samples, can be negative)
tomwalters@8 64 */
tomwalters@5 65 inline StrobePoint Strobe(int strobe_number) {
tomwalters@5 66 return strobes_.at(strobe_number);
tomwalters@0 67 };
tomwalters@0 68
tomwalters@8 69 /*! \brief Set the strobe weight
tomwalters@8 70 */
tomwalters@5 71 inline void SetWeight(int strobe_number, float weight) {
tomwalters@5 72 strobes_.at(strobe_number).weight = weight;
tomwalters@0 73 };
tomwalters@0 74
tomwalters@8 75 /*! \brief Set the strobe's working weight
tomwalters@8 76 */
tomwalters@5 77 inline void SetWorkingWeight(int strobe_number, float working_weight) {
tomwalters@5 78 strobes_.at(strobe_number).working_weight = working_weight;
tomwalters@0 79 };
tomwalters@0 80
tomwalters@8 81 /*! \brief Add a strobe to the list (must be in order)
tomwalters@8 82 */
tomwalters@5 83 inline void AddStrobe(int time, float weight) {
tomwalters@5 84 StrobePoint s;
tomwalters@5 85 s.time = time;
tomwalters@5 86 s.weight = weight;
tomwalters@5 87 strobes_.push_back(s);
tomwalters@0 88 };
tomwalters@0 89
tomwalters@8 90 /*! \brief Delete a strobe from the list
tomwalters@8 91 */
tomwalters@5 92 inline void DeleteFirstStrobe() {
tomwalters@5 93 strobes_.pop_front();
tomwalters@0 94 };
tomwalters@0 95
tomwalters@8 96 /*! \brief Get the number of strobes
tomwalters@8 97 */
tomwalters@5 98 inline int strobe_count() const {
tomwalters@5 99 return strobes_.size();
tomwalters@0 100 };
tomwalters@0 101
tomwalters@8 102 /*! \brief Shift the position of all strobes by subtracting offset from
tomwalters@8 103 * the time value of each
tomwalters@8 104 */
tomwalters@5 105 inline void ShiftStrobes(int offset) {
tomwalters@5 106 for (unsigned int i = 0; i < strobes_.size(); ++i)
tomwalters@5 107 strobes_[i].time -= offset;
tomwalters@0 108 };
tomwalters@0 109
tomwalters@0 110 private:
tomwalters@5 111 deque<StrobePoint> strobes_;
tomwalters@0 112 };
tomwalters@5 113 } // namespace aimc
tomwalters@0 114
tomwalters@0 115 #endif /* _AIMC_STROBE_LIST_H_ */
tomwalters@0 116