CLAM-Development  1.4.0
CleanTracks.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 #ifndef _CLEANTRACKS__
22 #define _CLEANTRACKS__
23 
24 #include "Segment.hxx"
25 #include "SpectralPeakArray.hxx"
26 #include "DataTypes.hxx"
27 #include "Processing.hxx"
28 #include "Array.hxx"
29 #include "SearchArray.hxx"
30 #include "CleanTracksConfig.hxx"
31 
32 namespace CLAM {
33 
34  class SpectralPeakArray;
35  class Segment;
36  class ProcessingConfig;
37 
38  /* CleanTracksConfig moved to CleanTracksConfig.hxx */
39 
40  typedef struct STrajectory
41  {
43  int beginPos;
44  int length;
50  friend bool operator >=(const struct STrajectory& first,const struct STrajectory& second)
51  {
52  return(first.id>=second.id);
53  }
54  friend bool operator <(const struct STrajectory& first,const struct STrajectory& second)
55  {
56  return(first.id<second.id);
57  }
58  }TTrajectory;
59 
60 
61 
62  class CleanTracks: public Processing
63  {
64  mutable CleanTracksConfig mConfig;
65 
66  const char *GetClassName() const {return "CleanTracks";}
67 
69  virtual bool ConcreteConfigure(const ProcessingConfig&);
70 
71  public:
72 
73  CleanTracks();
75  ~CleanTracks();
76 
77  //Configuration accessor
78  const ProcessingConfig &GetConfig() const { return mConfig;};
79 
80  //Peak Continuation for one frame
81  bool Do(Array<SpectralPeakArray*>& peakArrayArray);
82  bool Do(Segment& segment);
83  bool Do(void);
84 
85  int GetnCleanedTracks() const {return mTrajectoryArray.Size();};
86 
87  private:
88  void LoadTracks(Array<SpectralPeakArray*>& peakArrayArray);
89  void AddTrajectory(TTrajectory& trajectory);
90  void FindContinuations(void);
91  void JoinContinuations(Array<SpectralPeakArray*>& peakArrayArray);
92  void Clean(Array<SpectralPeakArray*>& peakArrayArray);
93  void UpdateTrackIds(Array<SpectralPeakArray*>& peakArrayArray);
94  void InterpolatePeaks(TTrajectory& trajectory, Array<SpectralPeakArray*>& peakArrayArray);
95 
96  TIndex FindTrajectoryPosition(TIndex id);
97 
98  TData mSamplingRate;
99  TData mSpecSize;
100  TSize mMaxDropOut;
101  TSize mMinLength;
102  TData mFreqDev;
103  Array<TTrajectory> mTrajectoryArray;
104  SearchArray<TTrajectory> mSearchTrajectories;
105 
106 
107 
108 
109  };
110 
111 };//namespace
112 
113 #endif
114