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@45: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@45: // you may not use this file except in compliance with the License. tomwalters@45: // You may obtain a copy of the License at tomwalters@0: // tomwalters@45: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@0: // tomwalters@45: // Unless required by applicable law or agreed to in writing, software tomwalters@45: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@45: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@45: // See the License for the specific language governing permissions and tomwalters@45: // limitations under the License. tomwalters@0: tomwalters@0: /*! tomwalters@0: * \file tomwalters@0: * \brief Modifiable List of Strobe Points - helper for SAI generation tomwalters@0: * tomwalters@9: * \author Tom Walters tomwalters@0: * \date created 2007/08/22 tomwalters@23: * \version \$Id$ tomwalters@0: */ tomwalters@0: tomwalters@11: #ifndef AIMC_SUPPORT_STROBELIST_H_ tomwalters@11: #define AIMC_SUPPORT_STROBELIST_H_ tomwalters@0: tomwalters@15: #include tomwalters@5: #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@8: time = 0; tomwalters@8: weight = 0.0f; tomwalters@8: working_weight = 0.0f; tomwalters@0: } 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@8: /*! \brief Return the strobe time (in samples, can be negative) tomwalters@8: */ tomwalters@5: inline StrobePoint Strobe(int strobe_number) { tomwalters@5: return strobes_.at(strobe_number); tomwalters@0: }; tomwalters@0: tomwalters@8: /*! \brief Set the strobe weight tomwalters@8: */ tomwalters@5: inline void SetWeight(int strobe_number, float weight) { tomwalters@5: strobes_.at(strobe_number).weight = weight; tomwalters@0: }; tomwalters@0: tomwalters@8: /*! \brief Set the strobe's working weight tomwalters@8: */ 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@8: /*! \brief Add a strobe to the list (must be in order) tomwalters@8: */ 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@8: /*! \brief Delete a strobe from the list tomwalters@8: */ tomwalters@5: inline void DeleteFirstStrobe() { tomwalters@5: strobes_.pop_front(); tomwalters@0: }; tomwalters@0: tomwalters@8: /*! \brief Get the number of strobes tomwalters@8: */ tomwalters@5: inline int strobe_count() const { tomwalters@5: return strobes_.size(); tomwalters@0: }; tomwalters@0: tomwalters@8: /*! \brief Shift the position of all strobes by subtracting offset from tomwalters@8: * the time value of each tomwalters@8: */ 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@11: #endif /* AIMC_SUPPORT_STROBELIST_H_ */ tomwalters@0: