Frame.hxx

Go to the documentation of this file.
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 
00022 #ifndef _Frame_
00023 #define _Frame_
00024 
00025 #include "DynamicType.hxx"
00026 #include "Spectrum.hxx"
00027 #include "Array.hxx"
00028 #include "IndexArray.hxx"
00029 #include "DataTypes.hxx"
00030 #include "OSDefines.hxx"
00031 #include "Err.hxx"
00032 #include "ProcessingData.hxx"
00033 #include "Fundamental.hxx"
00034 #include "SpectralPeakArray.hxx"
00035 #include "Audio.hxx"
00036 
00037 namespace CLAM {
00038 
00039 
00055 class Frame : public ProcessingData
00056 {
00057 public:
00058         DYNAMIC_TYPE_USING_INTERFACE (Frame, 14, ProcessingData);
00060         DYN_ATTRIBUTE (0, public, TData, CenterTime);
00062         DYN_ATTRIBUTE (1, public, TData, Duration);
00064         DYN_ATTRIBUTE (2, public, Spectrum, Spectrum);
00066         DYN_ATTRIBUTE (3, public, Spectrum, SinusoidalAnalSpectrum);
00068         DYN_ATTRIBUTE (4, public, SpectralPeakArray, SpectralPeakArray);
00070         DYN_ATTRIBUTE (5, public, Fundamental, Fundamental);
00072         DYN_ATTRIBUTE (6, public, Spectrum, OutSpec);
00074         DYN_ATTRIBUTE (7, public, Spectrum, ResidualSpec);
00076         DYN_ATTRIBUTE (8, public, Spectrum, SinusoidalSpec);
00077         /*Audio chunk that has been used for generating spectral data, will usually be
00078         a previously windowed audio chunk*/
00080         DYN_ATTRIBUTE (9, public, Audio, AudioFrame);
00082         DYN_ATTRIBUTE (10, public, Audio, SinusoidalAudioFrame);
00084         DYN_ATTRIBUTE (11, public, Audio, ResidualAudioFrame);
00086         DYN_ATTRIBUTE (12, public, Audio, SynthAudioFrame);
00088         DYN_ATTRIBUTE (13, public, bool, IsHarmonic);
00089 
00090 protected:
00091         void DefaultInit();
00092 
00093 public:
00094         //Accessory getters and setters. Note: for efficiency you need to work directly on the dynamic attributes
00095 
00096         //For Spectrum
00101         TData GetMag(TData freq) const;
00102 
00107         TData GetMag(TIndex pos) const ;
00108 
00113         TData GetPhase(TData freq) const ;
00114 
00119         TData GetPhase(TIndex pos) const ;
00120 
00121 
00122 
00127         void SetMag(TData freq, TData newMag);
00128 
00133         void SetMag(TIndex pos, TData newMag);
00134 
00139         void SetPhase(TData freq, TData newPhase);
00140 
00145         void SetPhase(TIndex pos, TData newPhase);
00146 
00147         //For Peak Array
00148 
00153         SpectralPeak GetSpectralPeak(TIndex pos) const;
00154 
00159         SpectralPeak GetThruIndexSpectralPeak(TIndex pos) const ;
00160 
00166         void SetSpectralPeak(TIndex pos,const SpectralPeak& spectralPeak,TIndex index=-1);
00167 
00174         void InsertSpectralPeak(TIndex pos,const SpectralPeak& spectralPeak,
00175         bool insertIndex=false,TIndex index=-1);
00176 
00182         void AddSpectralPeak(const SpectralPeak& spectralPeak,bool addIndex=false,TIndex index=-1);
00183 
00188         void DeleteSpectralPeak(TIndex pos,bool deleteIndex=false);
00189 
00190         //For Residual
00191 
00196         TData GetResMag(TData freq) const;
00197 
00202         TData GetResMag(TIndex pos) const ;
00203 
00208         TData GetResPhase(TData freq) const ;
00209 
00214         TData GetResPhase(TIndex pos) const ;
00215 
00216 
00221         void SetResMag(TData freq, TData newMag);
00222 
00227         void SetResMag(TIndex pos, TData newMag);
00228 
00233         void SetResPhase(TData freq, TData newPhase);
00234 
00239         void SetResPhase(TIndex pos, TData newPhase);
00240 
00241         //For Fundamental
00242 
00247         TData GetFundamentalFreq(TIndex pos=0)const;
00248 
00253         TData GetFundamentalErr(TIndex pos=0);
00254 
00259         void SetFundamentalFreq(TIndex pos,TData newFreq)const;
00260 
00265         void SetFundamentalErr(TIndex pos,TData newErr)const;
00266 
00267         /*Comparison Operators*/
00268 
00273         bool operator ==(const Frame& newFrame) const ;
00274 
00279         bool operator !=(const Frame& newFrame) const ;
00280 
00285         bool operator <(const Frame& newFrame) const ;
00286 
00291         bool operator <=(const Frame& newFrame) const ;
00292 
00297         bool operator >(const Frame& newFrame) const ;
00298 
00303         bool operator >=(const Frame& newFrame) const ;
00304 
00305 };
00306 
00307 };//namespace
00308 
00309 #endif
00310 
Generated by  doxygen 1.6.3