Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2012 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef MARSYAS_TIMELINE_H 00020 #define MARSYAS_TIMELINE_H 00021 00022 #include <marsyas/FileName.h> 00023 #include <marsyas/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 //Color color; 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_real srate_; 00081 mrs_real 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 mrs_bool setSampleRate(mrs_real srate); 00108 00109 void removeRegion(mrs_natural regionNum); 00110 00111 mrs_natural numClasses() const; 00112 //mrs_natural sampleRegion(mrs_natural sample) const; 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, mrs_string lexicon_labels); 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 //void print_mp3(FILE *fp); 00128 //void print_mmf(FILE *fp); 00129 /* void color(FeatMatrix &map); */ 00130 00131 }; 00132 00133 }//namespace Marsyas 00134 00135 00136 00137 #endif 00138 00139 00140 00141 00142 00143 00144 00145