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