00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MARSYAS_TIMELINE_H
00020 #define MARSYAS_TIMELINE_H
00021
00022 #include "FileName.h"
00023 #include "realvec.h"
00024 #include "Color.h"
00025
00026 #include <string>
00027 #include <algorithm>
00028 #include "Communicator.h"
00029
00030 #include <vector>
00031
00032 namespace Marsyas
00033 {
00064 struct marsyas_EXPORT TimeRegion
00065 {
00066 mrs_natural start;
00067 mrs_natural classId;
00068
00069 mrs_natural end;
00070 mrs_string name;
00071 };
00072
00073 class marsyas_EXPORT TimeLine
00074 {
00075 protected:
00076 mrs_string filename_;
00077 mrs_natural numRegions_;
00078 mrs_natural lineSize_;
00079 mrs_natural size_;
00080 mrs_natural srate_;
00081 mrs_natural psrate_;
00082
00083
00084 std::vector<TimeRegion> regions_;
00085
00086 public:
00087 TimeLine();
00088 ~TimeLine();
00089
00090 void clear();
00091 void regular(mrs_natural spacing, mrs_natural size, mrs_natural lineSize = MRS_DEFAULT_SLICE_NSAMPLES);
00092 void segment(realvec segmentation, mrs_natural lineSize = MRS_DEFAULT_SLICE_NSAMPLES);
00093
00094 mrs_string filename() const {return filename_;};
00095 mrs_natural size()const {return size_;};
00096 mrs_natural lineSize()const {return lineSize_;};
00097
00098 mrs_natural numRegions() const {return numRegions_;};
00099 std::vector<mrs_string> getRegionNames() const;
00100 mrs_natural regionStart(mrs_natural regionNum) const;
00101 mrs_natural regionEnd(mrs_natural regionNum) const;
00102 mrs_string regionName(mrs_natural regionNum) const;
00103 mrs_real regionClass(mrs_natural regionNum) const;
00104
00105 void setRegionName(mrs_natural regionNum, mrs_string name);
00106 void setRegionClass(mrs_natural regionNum, mrs_natural classId);
00107 void setSampleRate(mrs_real srate);
00108
00109 void removeRegion(mrs_natural regionNum);
00110
00111 mrs_natural numClasses() const;
00112
00113 mrs_natural sampleClass(mrs_natural sample) const;
00114
00115 void smooth(mrs_natural smoothSize);
00116
00117 void info() const;
00118 bool load(mrs_string filename);
00119 void write(mrs_string filename);
00120 friend std::ostream& operator<<(std::ostream&, const TimeLine&);
00121
00122 void receive(Communicator* com);
00123 void send(Communicator* com);
00124
00125 void print(FILE *fp);
00126 void printnew(FILE *fp);
00127
00128
00129
00130
00131 };
00132
00133 }
00134
00135
00136
00137 #endif
00138
00139
00140
00141
00142
00143
00144
00145