00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 #ifndef _CLEANTRACKS__ 00022 #define _CLEANTRACKS__ 00023 00024 #include "Segment.hxx" 00025 #include "SpectralPeakArray.hxx" 00026 #include "DataTypes.hxx" 00027 #include "Processing.hxx" 00028 #include "Array.hxx" 00029 #include "SearchArray.hxx" 00030 #include "CleanTracksConfig.hxx" 00031 00032 namespace CLAM { 00033 00034 class SpectralPeakArray; 00035 class Segment; 00036 class ProcessingConfig; 00037 00038 /* CleanTracksConfig moved to CleanTracksConfig.hxx */ 00039 00040 typedef struct STrajectory 00041 { 00042 TIndex id; 00043 int beginPos; 00044 int length; 00045 TData initialFreq; 00046 TData finalFreq; 00047 TData initialMag; 00048 TData finalMag; 00049 int continuedAtId; 00050 friend bool operator >=(const struct STrajectory& first,const struct STrajectory& second) 00051 { 00052 return(first.id>=second.id); 00053 } 00054 friend bool operator <(const struct STrajectory& first,const struct STrajectory& second) 00055 { 00056 return(first.id<second.id); 00057 } 00058 }TTrajectory; 00059 00060 00061 00062 class CleanTracks: public Processing 00063 { 00064 mutable CleanTracksConfig mConfig; 00065 00066 const char *GetClassName() const {return "CleanTracks";} 00067 00069 virtual bool ConcreteConfigure(const ProcessingConfig&); 00070 00071 public: 00072 00073 CleanTracks(); 00074 CleanTracks(const CleanTracksConfig &c); 00075 ~CleanTracks(); 00076 00077 //Configuration accessor 00078 const ProcessingConfig &GetConfig() const { return mConfig;}; 00079 00080 //Peak Continuation for one frame 00081 bool Do(Array<SpectralPeakArray*>& peakArrayArray); 00082 bool Do(Segment& segment); 00083 bool Do(void); 00084 00085 int GetnCleanedTracks() const {return mTrajectoryArray.Size();}; 00086 00087 private: 00088 void LoadTracks(Array<SpectralPeakArray*>& peakArrayArray); 00089 void AddTrajectory(TTrajectory& trajectory); 00090 void FindContinuations(void); 00091 void JoinContinuations(Array<SpectralPeakArray*>& peakArrayArray); 00092 void Clean(Array<SpectralPeakArray*>& peakArrayArray); 00093 void UpdateTrackIds(Array<SpectralPeakArray*>& peakArrayArray); 00094 void InterpolatePeaks(TTrajectory& trajectory, Array<SpectralPeakArray*>& peakArrayArray); 00095 00096 TIndex FindTrajectoryPosition(TIndex id); 00097 00098 TData mSamplingRate; 00099 TData mSpecSize; 00100 TSize mMaxDropOut; 00101 TSize mMinLength; 00102 TData mFreqDev; 00103 Array<TTrajectory> mTrajectoryArray; 00104 SearchArray<TTrajectory> mSearchTrajectories; 00105 00106 00107 00108 00109 }; 00110 00111 };//namespace 00112 00113 #endif 00114