annotate src/Support/StrobeList.h @ 23:491b1b1d1dc5

-Added AIMCopy, a replacement for HTK's HCopy -Set "Id" keyword on all .cc, .h and .py files -Added FileList class to aupport AIMCopy -Added a first go at a Module factory class. It's not to be used at the moment, but it will serve as a reminder to implement a proper factory soon.
author tomwalters
date Tue, 23 Feb 2010 12:47:01 +0000
parents b4cafba48e9d
children c5f5e9569863
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@9 23 * \author Tom Walters <tom@acousticscale.org>
tomwalters@0 24 * \date created 2007/08/22
tomwalters@23 25 * \version \$Id$
tomwalters@0 26 */
tomwalters@0 27
tomwalters@11 28 #ifndef AIMC_SUPPORT_STROBELIST_H_
tomwalters@11 29 #define AIMC_SUPPORT_STROBELIST_H_
tomwalters@0 30
tomwalters@15 31 #include <cmath>
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 class StrobeList {
tomwalters@0 48 public:
tomwalters@0 49 /*! \brief Create a new strobe list
tomwalters@0 50 */
tomwalters@0 51 inline StrobeList() {
tomwalters@5 52 strobes_.resize(0);
tomwalters@0 53 };
tomwalters@0 54
tomwalters@0 55 inline ~StrobeList() {
tomwalters@0 56 };
tomwalters@0 57
tomwalters@8 58 /*! \brief Return the strobe time (in samples, can be negative)
tomwalters@8 59 */
tomwalters@5 60 inline StrobePoint Strobe(int strobe_number) {
tomwalters@5 61 return strobes_.at(strobe_number);
tomwalters@0 62 };
tomwalters@0 63
tomwalters@8 64 /*! \brief Set the strobe weight
tomwalters@8 65 */
tomwalters@5 66 inline void SetWeight(int strobe_number, float weight) {
tomwalters@5 67 strobes_.at(strobe_number).weight = weight;
tomwalters@0 68 };
tomwalters@0 69
tomwalters@8 70 /*! \brief Set the strobe's working weight
tomwalters@8 71 */
tomwalters@5 72 inline void SetWorkingWeight(int strobe_number, float working_weight) {
tomwalters@5 73 strobes_.at(strobe_number).working_weight = working_weight;
tomwalters@0 74 };
tomwalters@0 75
tomwalters@8 76 /*! \brief Add a strobe to the list (must be in order)
tomwalters@8 77 */
tomwalters@5 78 inline void AddStrobe(int time, float weight) {
tomwalters@5 79 StrobePoint s;
tomwalters@5 80 s.time = time;
tomwalters@5 81 s.weight = weight;
tomwalters@5 82 strobes_.push_back(s);
tomwalters@0 83 };
tomwalters@0 84
tomwalters@8 85 /*! \brief Delete a strobe from the list
tomwalters@8 86 */
tomwalters@5 87 inline void DeleteFirstStrobe() {
tomwalters@5 88 strobes_.pop_front();
tomwalters@0 89 };
tomwalters@0 90
tomwalters@8 91 /*! \brief Get the number of strobes
tomwalters@8 92 */
tomwalters@5 93 inline int strobe_count() const {
tomwalters@5 94 return strobes_.size();
tomwalters@0 95 };
tomwalters@0 96
tomwalters@8 97 /*! \brief Shift the position of all strobes by subtracting offset from
tomwalters@8 98 * the time value of each
tomwalters@8 99 */
tomwalters@5 100 inline void ShiftStrobes(int offset) {
tomwalters@5 101 for (unsigned int i = 0; i < strobes_.size(); ++i)
tomwalters@5 102 strobes_[i].time -= offset;
tomwalters@0 103 };
tomwalters@0 104
tomwalters@0 105 private:
tomwalters@5 106 deque<StrobePoint> strobes_;
tomwalters@0 107 };
tomwalters@5 108 } // namespace aimc
tomwalters@0 109
tomwalters@11 110 #endif /* AIMC_SUPPORT_STROBELIST_H_ */
tomwalters@0 111