annotate src/Support/StrobeList.h @ 611:0fbaf443ec82

Carfac C++ revision 3, indluding more style improvements. The output structs are now classes again, and have separate storage methods for each output structure along with flags in the Run and RunSegment methods to allow for only storing NAPs if desired.
author alexbrandmeyer
date Fri, 17 May 2013 19:52:45 +0000
parents c5f5e9569863
children
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@45 6 // Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@45 7 // you may not use this file except in compliance with the License.
tomwalters@45 8 // You may obtain a copy of the License at
tomwalters@0 9 //
tomwalters@45 10 // http://www.apache.org/licenses/LICENSE-2.0
tomwalters@0 11 //
tomwalters@45 12 // Unless required by applicable law or agreed to in writing, software
tomwalters@45 13 // distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@45 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@45 15 // See the License for the specific language governing permissions and
tomwalters@45 16 // limitations under the License.
tomwalters@0 17
tomwalters@0 18 /*!
tomwalters@0 19 * \file
tomwalters@0 20 * \brief Modifiable List of Strobe Points - helper for SAI generation
tomwalters@0 21 *
tomwalters@9 22 * \author Tom Walters <tom@acousticscale.org>
tomwalters@0 23 * \date created 2007/08/22
tomwalters@23 24 * \version \$Id$
tomwalters@0 25 */
tomwalters@0 26
tomwalters@11 27 #ifndef AIMC_SUPPORT_STROBELIST_H_
tomwalters@11 28 #define AIMC_SUPPORT_STROBELIST_H_
tomwalters@0 29
tomwalters@15 30 #include <cmath>
tomwalters@5 31 #include <deque>
tomwalters@0 32
tomwalters@5 33 namespace aimc {
tomwalters@5 34 using std::deque;
tomwalters@5 35 struct StrobePoint {
tomwalters@5 36 int time;
tomwalters@5 37 float weight;
tomwalters@5 38 float working_weight;
tomwalters@0 39 StrobePoint() {
tomwalters@8 40 time = 0;
tomwalters@8 41 weight = 0.0f;
tomwalters@8 42 working_weight = 0.0f;
tomwalters@0 43 }
tomwalters@0 44 };
tomwalters@0 45
tomwalters@0 46 class StrobeList {
tomwalters@0 47 public:
tomwalters@0 48 /*! \brief Create a new strobe list
tomwalters@0 49 */
tomwalters@0 50 inline StrobeList() {
tomwalters@5 51 strobes_.resize(0);
tomwalters@0 52 };
tomwalters@0 53
tomwalters@0 54 inline ~StrobeList() {
tomwalters@0 55 };
tomwalters@0 56
tomwalters@8 57 /*! \brief Return the strobe time (in samples, can be negative)
tomwalters@8 58 */
tomwalters@5 59 inline StrobePoint Strobe(int strobe_number) {
tomwalters@5 60 return strobes_.at(strobe_number);
tomwalters@0 61 };
tomwalters@0 62
tomwalters@8 63 /*! \brief Set the strobe weight
tomwalters@8 64 */
tomwalters@5 65 inline void SetWeight(int strobe_number, float weight) {
tomwalters@5 66 strobes_.at(strobe_number).weight = weight;
tomwalters@0 67 };
tomwalters@0 68
tomwalters@8 69 /*! \brief Set the strobe's working weight
tomwalters@8 70 */
tomwalters@5 71 inline void SetWorkingWeight(int strobe_number, float working_weight) {
tomwalters@5 72 strobes_.at(strobe_number).working_weight = working_weight;
tomwalters@0 73 };
tomwalters@0 74
tomwalters@8 75 /*! \brief Add a strobe to the list (must be in order)
tomwalters@8 76 */
tomwalters@5 77 inline void AddStrobe(int time, float weight) {
tomwalters@5 78 StrobePoint s;
tomwalters@5 79 s.time = time;
tomwalters@5 80 s.weight = weight;
tomwalters@5 81 strobes_.push_back(s);
tomwalters@0 82 };
tomwalters@0 83
tomwalters@8 84 /*! \brief Delete a strobe from the list
tomwalters@8 85 */
tomwalters@5 86 inline void DeleteFirstStrobe() {
tomwalters@5 87 strobes_.pop_front();
tomwalters@0 88 };
tomwalters@0 89
tomwalters@8 90 /*! \brief Get the number of strobes
tomwalters@8 91 */
tomwalters@5 92 inline int strobe_count() const {
tomwalters@5 93 return strobes_.size();
tomwalters@0 94 };
tomwalters@0 95
tomwalters@8 96 /*! \brief Shift the position of all strobes by subtracting offset from
tomwalters@8 97 * the time value of each
tomwalters@8 98 */
tomwalters@5 99 inline void ShiftStrobes(int offset) {
tomwalters@5 100 for (unsigned int i = 0; i < strobes_.size(); ++i)
tomwalters@5 101 strobes_[i].time -= offset;
tomwalters@0 102 };
tomwalters@0 103
tomwalters@0 104 private:
tomwalters@5 105 deque<StrobePoint> strobes_;
tomwalters@0 106 };
tomwalters@5 107 } // namespace aimc
tomwalters@0 108
tomwalters@11 109 #endif /* AIMC_SUPPORT_STROBELIST_H_ */
tomwalters@0 110