MelFilterBank.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 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 __MELFILTERBANK__
00023 #define __MELFILTERBANK__
00024 
00025 #include "Processing.hxx"
00026 #include "Spectrum.hxx"
00027 #include "MelSpectrum.hxx"
00028 #include "Array.hxx"
00029 #include "InPort.hxx"
00030 #include "OutPort.hxx"
00031 
00032 namespace CLAM
00033 {
00034         
00035         class MelFilterBankConfig : public ProcessingConfig
00036         {
00037         public:
00038                 DYNAMIC_TYPE_USING_INTERFACE( MelFilterBankConfig, 6, ProcessingConfig );
00040                 DYN_ATTRIBUTE( 0, public, TSize,       SpectrumSize );
00042                 DYN_ATTRIBUTE( 1, public, TData,       SpectralRange );
00044                 DYN_ATTRIBUTE( 2, public, TData,       LowCutoff );
00046                 DYN_ATTRIBUTE( 3, public, TData,       HighCutoff );
00048                 DYN_ATTRIBUTE( 4, public, TSize,       NumBands );
00050                 DYN_ATTRIBUTE( 5, public, bool,        UsePower );
00051 
00052         protected:
00053                 void DefaultInit();
00054         };
00055 
00067         class MelFilterBank : public Processing
00068         {
00069         public:
00070                 MelFilterBank();
00071 
00072                 MelFilterBank( const MelFilterBankConfig& );
00073 
00074                 ~MelFilterBank();
00075 
00076                 bool Do();
00077 
00087                 bool Do(const Spectrum& s, MelSpectrum& ms );
00088 
00089                 const ProcessingConfig& GetConfig() const
00090                 {
00091                         return mConfig;
00092                 }
00093 
00094                 virtual const char* GetClassName() const
00095                 {
00096                         return "MelFilterBank";
00097                 }
00098 
00099         protected:
00100 
00101                 virtual bool ConcreteConfigure( const ProcessingConfig& cfg );
00102 
00103         protected:
00104 
00111                 TData Mel( TData linFreq );
00112 
00113                 void InitializeTables();
00114 
00115         private:
00116 
00117                 MelFilterBankConfig mConfig;
00118                 Array<TIndex>       mMelBand;
00119                 DataArray           mFilterWeights;
00120                 TIndex              mLowIdx;
00121                 TIndex              mHighIdx;
00122                 InPort<Spectrum> mIn;
00123                 OutPort<MelSpectrum> mOut;
00124         };
00125 }
00126 
00127 
00128 #endif // MelFilterBank.hxx
00129 
Generated by  doxygen 1.6.3