annotate trunk/src/Support/StrobeList.h @ 277:6b4921704eb1

- Ported over HTK file output - Added some more meat to the Slaney IIR gammatone implementation - Ported over the AIM-MAT sf2003 parabola strobe algorithm - Finished making the SAI implementation compile - Ported over the strobe list class (now uses STL deques internally)
author tomwalters
date Thu, 18 Feb 2010 16:55:40 +0000
parents e14c70d1b171
children e55d0c225a57
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@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@277 31 #include <deque>
tomwalters@268 32 #include <math.h>
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@277 41 time = 0;
tomwalters@277 42 weight = 0.0f;
tomwalters@277 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@268 63 //! \brief Return the strobe time (in samples, can be negative)
tomwalters@277 64 inline StrobePoint Strobe(int strobe_number) {
tomwalters@277 65 return strobes_.at(strobe_number);
tomwalters@268 66 };
tomwalters@268 67
tomwalters@268 68 //! \brief Set the strobe weight
tomwalters@277 69 inline void SetWeight(int strobe_number, float weight) {
tomwalters@277 70 strobes_.at(strobe_number).weight = weight;
tomwalters@268 71 };
tomwalters@268 72
tomwalters@268 73 //! \brief Set the strobe's working weight
tomwalters@277 74 inline void SetWorkingWeight(int strobe_number, float working_weight) {
tomwalters@277 75 strobes_.at(strobe_number).working_weight = working_weight;
tomwalters@268 76 };
tomwalters@268 77
tomwalters@268 78 //! \brief Add a strobe to the list (must be in order)
tomwalters@277 79 inline void AddStrobe(int time, float weight) {
tomwalters@277 80 StrobePoint s;
tomwalters@277 81 s.time = time;
tomwalters@277 82 s.weight = weight;
tomwalters@277 83 strobes_.push_back(s);
tomwalters@268 84 };
tomwalters@268 85
tomwalters@268 86 //! \brief Delete a strobe from the list
tomwalters@277 87 inline void DeleteFirstStrobe() {
tomwalters@277 88 strobes_.pop_front();
tomwalters@268 89 };
tomwalters@268 90
tomwalters@268 91 //! \brief Get the number of strobes
tomwalters@277 92 inline int strobe_count() const {
tomwalters@277 93 return strobes_.size();
tomwalters@268 94 };
tomwalters@268 95
tomwalters@277 96 //! \brief Shift the position of all strobes by subtracting offset from
tomwalters@268 97 //! the time value of each
tomwalters@277 98 inline void ShiftStrobes(int offset) {
tomwalters@277 99 for (unsigned int i = 0; i < strobes_.size(); ++i)
tomwalters@277 100 strobes_[i].time -= offset;
tomwalters@268 101 };
tomwalters@268 102
tomwalters@268 103 private:
tomwalters@277 104 deque<StrobePoint> strobes_;
tomwalters@268 105 };
tomwalters@277 106 } // namespace aimc
tomwalters@268 107
tomwalters@268 108 #endif /* _AIMC_STROBE_LIST_H_ */
tomwalters@268 109