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@318: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@318: // you may not use this file except in compliance with the License. tomwalters@318: // You may obtain a copy of the License at tomwalters@268: // tomwalters@318: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@268: // tomwalters@318: // Unless required by applicable law or agreed to in writing, software tomwalters@318: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@318: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@318: // See the License for the specific language governing permissions and tomwalters@318: // limitations under the License. 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: