FrameDescriptors.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 __FrameDescriptors__
00023 #define __FrameDescriptors__
00024 
00025 #include "Descriptor.hxx"
00026 
00027 #include "AudioDescriptors.hxx"
00028 #include "SpectralDescriptors.hxx"
00029 #include "SpectralPeakDescriptors.hxx"
00030 #include "MorphologicalFrameDescriptors.hxx"
00031 
00032 namespace CLAM{
00033 
00034 
00035 class Frame;
00036 
00037 /*
00038  * This class holds Descriptors computed from Frame data. Right now no specific
00039  * descriptors are computed for frame (only for spectrums, audios... that are held
00040  * inside the frame. TODO: add specific descriptors.
00041  *
00042  */
00043 class FrameDescriptors : public Descriptor
00044 {
00045 public:
00046         DYNAMIC_TYPE_USING_INTERFACE (FrameDescriptors, 10, Descriptor);
00048         DYN_ATTRIBUTE (0, public, SpectralDescriptors, SpectrumD);
00050         DYN_ATTRIBUTE (1, public, SpectralPeakDescriptors, SpectralPeakD);
00052         DYN_ATTRIBUTE (2, public, SpectralDescriptors, ResidualSpecD);
00054         DYN_ATTRIBUTE (3, public, SpectralDescriptors, SinusoidalSpecD);
00055         /*Audio chunk that has been used for generating spectral data, will usually be
00056         a previously windowed audio chunk*/
00058         DYN_ATTRIBUTE (4, public, AudioDescriptors, AudioFrameD);
00060         DYN_ATTRIBUTE (5, public, AudioDescriptors, SinusoidalAudioFrameD);
00062         DYN_ATTRIBUTE (6, public, AudioDescriptors, ResidualAudioFrameD);
00064         DYN_ATTRIBUTE (7, public, AudioDescriptors, SynthAudioFrameD);
00065         
00066 
00068         DYN_ATTRIBUTE (8, public, MorphologicalFrameDescriptors, MorphologicalFrameD);
00069 
00071         DYN_ATTRIBUTE (9, public, TTime, CenterTime);   
00072 
00073         //Note: some specific frame descriptors should be added
00074 public:
00075         FrameDescriptors(Frame* pFrame);
00076         FrameDescriptors(TData initVal);
00077 
00078         const Frame* GetpFrame() const;
00079         void SetpFrame(const Frame* pFrame);
00080         void Compute();
00081         void ConcreteCompute();
00082         
00083         TData GetFundamental() {return mpFrame->GetFundamental().GetFreq(0);}
00084 
00085 private:
00086         void DefaultInit();
00087         void CopyInit(const FrameDescriptors & copied);
00088 
00089 private:
00090         const Frame* mpFrame;
00091 
00092 };
00093 
00094 FrameDescriptors operator * (const FrameDescriptors& a,const FrameDescriptors& b);
00095 FrameDescriptors operator + (const FrameDescriptors& a,const FrameDescriptors& b);
00096 FrameDescriptors operator * (const FrameDescriptors& a,TData mult);
00097 FrameDescriptors operator * (TData mult,const FrameDescriptors& a);
00098 FrameDescriptors operator - (const FrameDescriptors& a,const FrameDescriptors& b);
00099 FrameDescriptors operator / (const FrameDescriptors& a,TData div);
00100 
00101 template<>
00102 inline FrameDescriptors CLAM_max (const FrameDescriptors& a,const FrameDescriptors& b)
00103 {
00104         FrameDescriptors  tmpD(a);
00105         if(a.HasSpectralPeakD() && b.HasSpectralPeakD())
00106         {
00107                 tmpD.SetSpectralPeakD(CLAM_max(a.GetSpectralPeakD(),b.GetSpectralPeakD()));
00108         }
00109         if(a.HasSpectrumD() && b.HasSpectrumD())
00110         {
00111                 tmpD.SetSpectrumD(CLAM_max(a.GetSpectrumD(),b.GetSpectrumD()));
00112         }
00113         if(a.HasResidualSpecD() && b.HasResidualSpecD())
00114         {
00115                 tmpD.SetResidualSpecD(CLAM_max(a.GetResidualSpecD(),b.GetResidualSpecD()));
00116         }
00117         if(a.HasSinusoidalSpecD() && b.HasSinusoidalSpecD())
00118         {
00119                 tmpD.SetSinusoidalSpecD(CLAM_max(a.GetSinusoidalSpecD(),b.GetSinusoidalSpecD()));
00120         }
00121         if(a.HasAudioFrameD() && b.HasAudioFrameD())
00122         {
00123                 tmpD.SetAudioFrameD(CLAM_max(a.GetAudioFrameD(),b.GetAudioFrameD()));
00124         }
00125         if(a.HasSinusoidalAudioFrameD() && b.HasSinusoidalAudioFrameD())
00126         {
00127                 tmpD.SetSinusoidalAudioFrameD(CLAM_max(a.GetSinusoidalAudioFrameD(),b.GetSinusoidalAudioFrameD()));
00128         }
00129         if(a.HasResidualAudioFrameD() && b.HasResidualAudioFrameD())
00130         {
00131                 tmpD.SetResidualAudioFrameD(CLAM_max(a.GetResidualAudioFrameD(),b.GetResidualAudioFrameD()));
00132         }
00133         if(a.HasSynthAudioFrameD() && b.HasSynthAudioFrameD())
00134         {
00135                 tmpD.SetSynthAudioFrameD(CLAM_max(a.GetSynthAudioFrameD(),b.GetSynthAudioFrameD()));
00136         }
00137         return tmpD;
00138 }
00139 
00140 template<>
00141 inline FrameDescriptors CLAM_min (const FrameDescriptors& a,const FrameDescriptors& b)
00142 {
00143         FrameDescriptors  tmpD(a);
00144         if(a.HasSpectralPeakD() && b.HasSpectralPeakD())
00145         {
00146                 tmpD.SetSpectralPeakD(CLAM_min(a.GetSpectralPeakD(),b.GetSpectralPeakD()));
00147         }
00148         if(a.HasSpectrumD() && b.HasSpectrumD())
00149         {
00150                 tmpD.SetSpectrumD(CLAM_min(a.GetSpectrumD(),b.GetSpectrumD()));
00151         }
00152         if(a.HasResidualSpecD() && b.HasResidualSpecD())
00153         {
00154                 tmpD.SetResidualSpecD(CLAM_min(a.GetResidualSpecD(),b.GetResidualSpecD()));
00155         }
00156         if(a.HasSinusoidalSpecD() && b.HasSinusoidalSpecD())
00157         {
00158                 tmpD.SetSinusoidalSpecD(CLAM_min(a.GetSinusoidalSpecD(),b.GetSinusoidalSpecD()));
00159         }
00160         if(a.HasAudioFrameD() && b.HasAudioFrameD())
00161         {
00162                 tmpD.SetAudioFrameD(CLAM_min(a.GetAudioFrameD(),b.GetAudioFrameD()));
00163         }
00164         if(a.HasSinusoidalAudioFrameD() && b.HasSinusoidalAudioFrameD())
00165         {
00166                 tmpD.SetSinusoidalAudioFrameD(CLAM_min(a.GetSinusoidalAudioFrameD(),b.GetSinusoidalAudioFrameD()));
00167         }
00168         if(a.HasResidualAudioFrameD() && b.HasResidualAudioFrameD())
00169         {
00170                 tmpD.SetResidualAudioFrameD(CLAM_min(a.GetResidualAudioFrameD(),b.GetResidualAudioFrameD()));
00171         }
00172         if(a.HasSynthAudioFrameD() && b.HasSynthAudioFrameD())
00173         {
00174                 tmpD.SetSynthAudioFrameD(CLAM_min(a.GetSynthAudioFrameD(),b.GetSynthAudioFrameD()));
00175         }
00176         return tmpD;
00177 }
00178 
00179 
00180 
00181 
00182 };//CLAM
00183 
00184 
00185 
00186 #endif
00187 
Generated by  doxygen 1.6.3