annotate trunk/src/Support/StrobeList.h @ 283:ef14c9f2c1d2

-Added modules template -Changed header guard style to be more consistent with the Google style guide -Added Doyxfile to generate doxygen documentation -Added structure diagram -Updated swig script to reflect new modules -Changes Gaussians back to using floats and changed tolerance on tests - doubles are unnecessary here
author tomwalters
date Fri, 19 Feb 2010 12:15:56 +0000
parents 41ea31faf90c
children 4b3a43b543dd
rev   line source
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@281 23 * \author Tom Walters <tom@acousticscale.org>
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@283 28 #ifndef AIMC_SUPPORT_STROBELIST_H_
tomwalters@283 29 #define AIMC_SUPPORT_STROBELIST_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 class StrobeList {
tomwalters@268 48 public:
tomwalters@268 49 /*! \brief Create a new strobe list
tomwalters@268 50 */
tomwalters@268 51 inline StrobeList() {
tomwalters@277 52 strobes_.resize(0);
tomwalters@268 53 };
tomwalters@268 54
tomwalters@268 55 inline ~StrobeList() {
tomwalters@268 56 };
tomwalters@268 57
tomwalters@280 58 /*! \brief Return the strobe time (in samples, can be negative)
tomwalters@280 59 */
tomwalters@277 60 inline StrobePoint Strobe(int strobe_number) {
tomwalters@277 61 return strobes_.at(strobe_number);
tomwalters@268 62 };
tomwalters@268 63
tomwalters@280 64 /*! \brief Set the strobe weight
tomwalters@280 65 */
tomwalters@277 66 inline void SetWeight(int strobe_number, float weight) {
tomwalters@277 67 strobes_.at(strobe_number).weight = weight;
tomwalters@268 68 };
tomwalters@268 69
tomwalters@280 70 /*! \brief Set the strobe's working weight
tomwalters@280 71 */
tomwalters@277 72 inline void SetWorkingWeight(int strobe_number, float working_weight) {
tomwalters@277 73 strobes_.at(strobe_number).working_weight = working_weight;
tomwalters@268 74 };
tomwalters@268 75
tomwalters@280 76 /*! \brief Add a strobe to the list (must be in order)
tomwalters@280 77 */
tomwalters@277 78 inline void AddStrobe(int time, float weight) {
tomwalters@277 79 StrobePoint s;
tomwalters@277 80 s.time = time;
tomwalters@277 81 s.weight = weight;
tomwalters@277 82 strobes_.push_back(s);
tomwalters@268 83 };
tomwalters@268 84
tomwalters@280 85 /*! \brief Delete a strobe from the list
tomwalters@280 86 */
tomwalters@277 87 inline void DeleteFirstStrobe() {
tomwalters@277 88 strobes_.pop_front();
tomwalters@268 89 };
tomwalters@268 90
tomwalters@280 91 /*! \brief Get the number of strobes
tomwalters@280 92 */
tomwalters@277 93 inline int strobe_count() const {
tomwalters@277 94 return strobes_.size();
tomwalters@268 95 };
tomwalters@268 96
tomwalters@280 97 /*! \brief Shift the position of all strobes by subtracting offset from
tomwalters@280 98 * the time value of each
tomwalters@280 99 */
tomwalters@277 100 inline void ShiftStrobes(int offset) {
tomwalters@277 101 for (unsigned int i = 0; i < strobes_.size(); ++i)
tomwalters@277 102 strobes_[i].time -= offset;
tomwalters@268 103 };
tomwalters@268 104
tomwalters@268 105 private:
tomwalters@277 106 deque<StrobePoint> strobes_;
tomwalters@268 107 };
tomwalters@277 108 } // namespace aimc
tomwalters@268 109
tomwalters@283 110 #endif /* AIMC_SUPPORT_STROBELIST_H_ */
tomwalters@268 111