Normalization.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 _Normalization_
00023 #define _Normalization_
00024 
00025 #include "Processing.hxx"
00026 #include "Audio.hxx"
00027 #include "OutControl.hxx"
00028 
00029 namespace CLAM
00030 {
00064         class NormalizationConfig: public ProcessingConfig
00065         {
00066         public:
00067                 DYNAMIC_TYPE_USING_INTERFACE (NormalizationConfig, 2, ProcessingConfig);
00068                 DYN_ATTRIBUTE (0, public, int, Type);
00069                 DYN_ATTRIBUTE (1, public, TSize, FrameSize);
00070 
00071                 void DefaultInit(void);
00072         };
00073         
00074         class Normalization: public Processing
00075         {
00076         private:
00077                 NormalizationConfig mConfig;
00078 
00082                 FloatOutControl mIsSilenceCtrl;
00083 
00084                 int mType;
00085                 TSize mFrameSize;
00086                 
00087                 bool ConcreteConfigure(const ProcessingConfig& c);
00088 
00089                 /*
00090                  * With this check an app can know if the passed audio is silence, 
00091                  * just consulting the value of the control.
00092                  */
00093                 void CheckSilence( int size );
00094 
00095         public:
00096 
00097                 Normalization();
00098                 Normalization(NormalizationConfig& c);
00099                 ~Normalization();
00100 
00101                 const char * GetClassName() const {return "Normalization";}
00102 
00103                 bool Do(void);
00104 
00105                 bool Do(Audio &in);
00106                 bool Do( const Audio& unnorm, Audio& norm );
00107                 
00108                 const ProcessingConfig &GetConfig() const { return mConfig;}
00109 
00110         protected:
00111                 
00112                 TData ComputeScaleFactorFromMaxEnergy( DataArray& inAudio );
00113                 TData ComputeScaleFactorFromAvgEnergy( DataArray& inAudio );
00114                 TData ComputeScaleFactorFromDominantEnergy( DataArray& inAudio );
00115 
00116         };
00117         
00118 }
00119 
00120 #endif
00121 
00122 
Generated by  doxygen 1.6.3