CLAM-Development  1.4.0
Frame.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 
22 #ifndef _Frame_
23 #define _Frame_
24 
25 #include "DynamicType.hxx"
26 #include "Spectrum.hxx"
27 #include "Array.hxx"
28 #include "IndexArray.hxx"
29 #include "DataTypes.hxx"
30 #include "OSDefines.hxx"
31 #include "Err.hxx"
32 #include "ProcessingData.hxx"
33 #include "Fundamental.hxx"
34 #include "SpectralPeakArray.hxx"
35 #include "Audio.hxx"
36 
37 namespace CLAM {
38 
39 
55 class Frame : public ProcessingData
56 {
57 public:
60  DYN_ATTRIBUTE (0, public, TData, CenterTime);
62  DYN_ATTRIBUTE (1, public, TData, Duration);
64  DYN_ATTRIBUTE (2, public, Spectrum, Spectrum);
66  DYN_ATTRIBUTE (3, public, Spectrum, SinusoidalAnalSpectrum);
72  DYN_ATTRIBUTE (6, public, Spectrum, OutSpec);
74  DYN_ATTRIBUTE (7, public, Spectrum, ResidualSpec);
76  DYN_ATTRIBUTE (8, public, Spectrum, SinusoidalSpec);
77  /*Audio chunk that has been used for generating spectral data, will usually be
78  a previously windowed audio chunk*/
80  DYN_ATTRIBUTE (9, public, Audio, AudioFrame);
82  DYN_ATTRIBUTE (10, public, Audio, SinusoidalAudioFrame);
84  DYN_ATTRIBUTE (11, public, Audio, ResidualAudioFrame);
86  DYN_ATTRIBUTE (12, public, Audio, SynthAudioFrame);
88  DYN_ATTRIBUTE (13, public, bool, IsHarmonic);
89 
90 protected:
91  void DefaultInit();
92 
93 public:
94  //Accessory getters and setters. Note: for efficiency you need to work directly on the dynamic attributes
95 
96  //For Spectrum
101  TData GetMag(TData freq) const;
102 
107  TData GetMag(TIndex pos) const ;
108 
113  TData GetPhase(TData freq) const ;
114 
119  TData GetPhase(TIndex pos) const ;
120 
121 
122 
127  void SetMag(TData freq, TData newMag);
128 
133  void SetMag(TIndex pos, TData newMag);
134 
139  void SetPhase(TData freq, TData newPhase);
140 
145  void SetPhase(TIndex pos, TData newPhase);
146 
147  //For Peak Array
148 
154 
160 
166  void SetSpectralPeak(TIndex pos,const SpectralPeak& spectralPeak,TIndex index=-1);
167 
174  void InsertSpectralPeak(TIndex pos,const SpectralPeak& spectralPeak,
175  bool insertIndex=false,TIndex index=-1);
176 
182  void AddSpectralPeak(const SpectralPeak& spectralPeak,bool addIndex=false,TIndex index=-1);
183 
188  void DeleteSpectralPeak(TIndex pos,bool deleteIndex=false);
189 
190  //For Residual
191 
196  TData GetResMag(TData freq) const;
197 
202  TData GetResMag(TIndex pos) const ;
203 
208  TData GetResPhase(TData freq) const ;
209 
214  TData GetResPhase(TIndex pos) const ;
215 
216 
221  void SetResMag(TData freq, TData newMag);
222 
227  void SetResMag(TIndex pos, TData newMag);
228 
233  void SetResPhase(TData freq, TData newPhase);
234 
239  void SetResPhase(TIndex pos, TData newPhase);
240 
241  //For Fundamental
242 
247  TData GetFundamentalFreq(TIndex pos=0)const;
248 
254 
259  void SetFundamentalFreq(TIndex pos,TData newFreq)const;
260 
265  void SetFundamentalErr(TIndex pos,TData newErr)const;
266 
267  /*Comparison Operators*/
268 
273  bool operator ==(const Frame& newFrame) const ;
274 
279  bool operator !=(const Frame& newFrame) const ;
280 
285  bool operator <(const Frame& newFrame) const ;
286 
291  bool operator <=(const Frame& newFrame) const ;
292 
297  bool operator >(const Frame& newFrame) const ;
298 
303  bool operator >=(const Frame& newFrame) const ;
304 
305 };
306 
307 };//namespace
308 
309 #endif
310