tomwalters@0: // Copyright 2007-2010, Thomas Walters tomwalters@0: // tomwalters@0: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@0: // http://www.acousticscale.org/AIMC tomwalters@0: // tomwalters@0: // This program is free software: you can redistribute it and/or modify tomwalters@0: // it under the terms of the GNU General Public License as published by tomwalters@0: // the Free Software Foundation, either version 3 of the License, or tomwalters@0: // (at your option) any later version. tomwalters@0: // tomwalters@0: // This program is distributed in the hope that it will be useful, tomwalters@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@0: // GNU General Public License for more details. tomwalters@0: // tomwalters@0: // You should have received a copy of the GNU General Public License tomwalters@0: // along with this program. If not, see . tomwalters@0: tomwalters@0: /*! tomwalters@0: * \file tomwalters@0: * \brief Modifiable List of Strobe Points - helper for SAI generation tomwalters@0: * tomwalters@0: * \author Tom Walters tomwalters@0: * \date created 2007/08/22 tomwalters@0: * \version \$Id: StrobeList.h 1 2010-02-02 11:04:50Z tcw $ tomwalters@0: */ tomwalters@0: tomwalters@5: #ifndef _AIMC_SUPPORT_STROBE_LIST_H_ tomwalters@5: #define _AIMC_SUPPORT_STROBE_LIST_H_ tomwalters@0: tomwalters@5: #include tomwalters@0: #include tomwalters@0: tomwalters@5: namespace aimc { tomwalters@5: using std::deque; tomwalters@5: struct StrobePoint { tomwalters@5: int time; tomwalters@5: float weight; tomwalters@5: float working_weight; tomwalters@0: StrobePoint() { tomwalters@5: time = 0; tomwalters@5: weight = 0.0f; tomwalters@5: working_weight = 0.0f; tomwalters@0: } tomwalters@0: }; tomwalters@0: tomwalters@0: /*! tomwalters@0: * \class Signal "Support/StrobeList.h" tomwalters@0: * \brief Modifiable List of Strobe Points, which must be ordered tomwalters@0: * tomwalters@0: */ tomwalters@0: class StrobeList { tomwalters@0: public: tomwalters@0: /*! \brief Create a new strobe list tomwalters@0: */ tomwalters@0: inline StrobeList() { tomwalters@5: strobes_.resize(0); tomwalters@0: }; tomwalters@0: tomwalters@0: inline ~StrobeList() { tomwalters@0: }; tomwalters@0: tomwalters@0: //! \brief Return the strobe time (in samples, can be negative) tomwalters@5: inline StrobePoint Strobe(int strobe_number) { tomwalters@5: return strobes_.at(strobe_number); tomwalters@0: }; tomwalters@0: tomwalters@0: //! \brief Set the strobe weight tomwalters@5: inline void SetWeight(int strobe_number, float weight) { tomwalters@5: strobes_.at(strobe_number).weight = weight; tomwalters@0: }; tomwalters@0: tomwalters@0: //! \brief Set the strobe's working weight tomwalters@5: inline void SetWorkingWeight(int strobe_number, float working_weight) { tomwalters@5: strobes_.at(strobe_number).working_weight = working_weight; tomwalters@0: }; tomwalters@0: tomwalters@0: //! \brief Add a strobe to the list (must be in order) tomwalters@5: inline void AddStrobe(int time, float weight) { tomwalters@5: StrobePoint s; tomwalters@5: s.time = time; tomwalters@5: s.weight = weight; tomwalters@5: strobes_.push_back(s); tomwalters@0: }; tomwalters@0: tomwalters@0: //! \brief Delete a strobe from the list tomwalters@5: inline void DeleteFirstStrobe() { tomwalters@5: strobes_.pop_front(); tomwalters@0: }; tomwalters@0: tomwalters@0: //! \brief Get the number of strobes tomwalters@5: inline int strobe_count() const { tomwalters@5: return strobes_.size(); tomwalters@0: }; tomwalters@0: tomwalters@5: //! \brief Shift the position of all strobes by subtracting offset from tomwalters@0: //! the time value of each tomwalters@5: inline void ShiftStrobes(int offset) { tomwalters@5: for (unsigned int i = 0; i < strobes_.size(); ++i) tomwalters@5: strobes_[i].time -= offset; tomwalters@0: }; tomwalters@0: tomwalters@0: private: tomwalters@5: deque strobes_; tomwalters@0: }; tomwalters@5: } // namespace aimc tomwalters@0: tomwalters@0: #endif /* _AIMC_STROBE_LIST_H_ */ tomwalters@0: