Marsyas
0.6.0-alpha
|
00001 // Copyright 2007-2010, Thomas Walters 00002 // 00003 // AIM-C: A C++ implementation of the Auditory Image Model 00004 // http://www.acousticscale.org/AIMC 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the "License"); 00007 // you may not use this file except in compliance with the License. 00008 // You may obtain a copy of the License at 00009 // 00010 // http://www.apache.org/licenses/LICENSE-2.0 00011 // 00012 // Unless required by applicable law or agreed to in writing, software 00013 // distributed under the License is distributed on an "AS IS" BASIS, 00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 // See the License for the specific language governing permissions and 00016 // limitations under the License. 00017 00027 #ifndef AIMC_SUPPORT_STROBELIST_H_ 00028 #define AIMC_SUPPORT_STROBELIST_H_ 00029 00030 #include <iostream> 00031 //using namespace std; 00032 00033 #include <cmath> 00034 #include <deque> 00035 #include <cstddef> 00036 00037 namespace Marsyas { 00038 using std::deque; 00039 struct StrobePoint { 00040 int time; 00041 double weight; 00042 double working_weight; 00043 StrobePoint() { 00044 time = 0; 00045 weight = 0.0; 00046 working_weight = 0.0; 00047 } 00048 }; 00049 00050 class StrobeList { 00051 public: 00054 inline StrobeList() { 00055 strobes_.resize(0); 00056 }; 00057 00058 inline ~StrobeList() { 00059 }; 00060 00063 inline StrobePoint Strobe(std::size_t strobe_number) { 00064 return strobes_.at(strobe_number); 00065 }; 00066 00069 inline void SetWeight(std::size_t strobe_number, double weight) { 00070 strobes_.at(strobe_number).weight = weight; 00071 }; 00072 00075 inline void SetWorkingWeight(std::size_t strobe_number, double working_weight) { 00076 strobes_.at(strobe_number).working_weight = working_weight; 00077 }; 00078 00081 inline void AddStrobe(int time, double weight) { 00082 StrobePoint s; 00083 s.time = time; 00084 s.weight = weight; 00085 strobes_.push_back(s); 00086 }; 00087 00090 inline void DeleteFirstStrobe() { 00091 strobes_.pop_front(); 00092 }; 00093 00096 inline std::size_t strobe_count() const { 00097 return strobes_.size(); 00098 }; 00099 00103 inline void ShiftStrobes(int offset) { 00104 for (unsigned int i = 0; i < strobes_.size(); ++i) 00105 strobes_[i].time -= offset; 00106 }; 00107 00108 void printStrobes() { 00109 for (unsigned int i = 0; i < strobes_.size(); ++i) { 00110 std::cout << strobes_[i].time << " " << strobes_[i].weight << strobes_[i].working_weight << std::endl; 00111 } 00112 00113 } 00114 00115 private: 00116 deque<StrobePoint> strobes_; 00117 }; 00118 } // namespace aimc 00119 00120 #endif /* AIMC_SUPPORT_STROBELIST_H_ */